Commit 74c50af2 authored by Łukasz Nowak's avatar Łukasz Nowak

Migrate most basic constraints.

parent 3af13229
......@@ -5,6 +5,9 @@
<portal_type id="Sale Invoice Transaction">
<item>SlapOSAccountingSaleInvoiceTransactionConstraint</item>
</portal_type>
<portal_type id="Sale Packing List">
<item>SlapOSAccountingSalePackingListConstraint</item>
</portal_type>
<portal_type id="Slave Instance">
<item>InstanceAccountingSynchronisation</item>
</portal_type>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Sheet" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SlapOSAccountingSalePackingListConstraint</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
......@@ -44,6 +44,22 @@
<key> <string>max_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>message_arity_not_in_range</string> </key>
<value> <string>Exactly one Currency shall be selected</string> </value>
</item>
<item>
<key> <string>message_arity_too_small</string> </key>
<value> <string>Exactly one Currency shall be selected</string> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_not_in_range</string> </key>
<value> <string>Exactly one Currency shall be selected</string> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_too_small</string> </key>
<value> <string>Exactly one Currency shall be selected</string> </value>
</item>
<item>
<key> <string>min_arity</string> </key>
<value> <int>1</int> </value>
......
......@@ -219,3 +219,122 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
invoice.newContent(portal_type='Invoice Line', quantity=2.,
price=1.)
self.assertFalse(message in self.getMessageList(invoice))
class TestSalePackingList(TestSlapOSConstraintMixin):
@withAbort
def test_lines(self):
message = 'Sale Packing List Line is not defined'
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery))
delivery.newContent(portal_type='Sale Packing List Line')
self.assertFalse(message in self.getMessageList(delivery))
@withAbort
def test_reference_not_empty(self):
message = 'Reference must be defined'
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
self.assertFalse(message in self.getMessageList(delivery))
delivery.setReference(None)
self.assertTrue(message in self.getMessageList(delivery))
@withAbort
def test_price_currency(self):
message = 'Exactly one Currency shall be selected'
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery))
resource = self.portal.service_module.newContent(portal_type='Service')
delivery.setPriceCurrency(resource.getRelativeUrl())
self.assertTrue(message in self.getMessageList(delivery))
currency_1 = self.portal.currency_module.newContent(portal_type='Currency')
currency_2 = self.portal.currency_module.newContent(portal_type='Currency')
delivery.setPriceCurrencyList([currency_1.getRelativeUrl(),
currency_2.getRelativeUrl()])
self.assertTrue(message in self.getMessageList(delivery))
delivery.setPriceCurrency(currency_1.getRelativeUrl())
self.assertFalse(message in self.getMessageList(delivery))
@withAbort
def _test_category_arrow(self, category):
message = "Arity Error for Relation ['%s'], arity is equal to "\
"0 but should be between 1 and 1" % category
message_2 = "Arity Error for Relation ['%s'], arity is equal to "\
"2 but should be between 1 and 1" % category
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
resource = self.portal.service_module.newContent(
portal_type='Service').getRelativeUrl()
person = self.portal.person_module.newContent(
portal_type='Person').getRelativeUrl()
organisation = self.portal.organisation_module.newContent(
portal_type='Organisation').getRelativeUrl()
key = '%s_list' % category
self.assertTrue(message in self.getMessageList(delivery))
delivery.edit(**{key: [resource]})
self.assertTrue(message in self.getMessageList(delivery))
delivery.edit(**{key: [person, organisation]})
self.assertTrue(message_2 in self.getMessageList(delivery))
delivery.edit(**{key: [person]})
self.assertFalse(message in self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery))
delivery.edit(**{key: [organisation]})
self.assertFalse(message in self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery))
def test_destination(self):
self._test_category_arrow('destination')
def test_destination_section(self):
self._test_category_arrow('destination_section')
def test_destination_decision(self):
self._test_category_arrow('destination_decision')
def test_source(self):
self._test_category_arrow('source')
def test_source_section(self):
self._test_category_arrow('source_section')
@withAbort
def test_specialise(self):
category = 'specialise'
message = "Arity Error for Relation ['%s'], arity is equal to "\
"0 but should be between 1 and 1" % category
message_2 = "Arity Error for Relation ['%s'], arity is equal to "\
"2 but should be between 1 and 1" % category
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
resource = self.portal.service_module.newContent(
portal_type='Service').getRelativeUrl()
stc_1 = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition').getRelativeUrl()
stc_2 = self.portal.sale_trade_condition_module.newContent(
portal_type='Sale Trade Condition').getRelativeUrl()
key = '%s_list' % category
self.assertTrue(message in self.getMessageList(delivery))
delivery.edit(**{key: [resource]})
self.assertTrue(message in self.getMessageList(delivery))
delivery.edit(**{key: [stc_1, stc_2]})
self.assertTrue(message_2 in self.getMessageList(delivery))
delivery.edit(**{key: [stc_1]})
self.assertFalse(message in self.getMessageList(delivery))
self.assertFalse(message_2 in self.getMessageList(delivery))
@withAbort
def test_start_date(self):
message = 'Property start_date must be defined'
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
self.assertTrue(message in self.getMessageList(delivery))
delivery.setStartDate('2012/01/01')
self.assertFalse(message in self.getMessageList(delivery))
185
\ No newline at end of file
186
\ No newline at end of file
Hosting Subscription | SlapOSAccountingHostingSubscriptionConstraint
Sale Invoice Transaction | SlapOSAccountingSaleInvoiceTransactionConstraint
Sale Packing List | SlapOSAccountingSalePackingListConstraint
Slave Instance | InstanceAccountingSynchronisation
Software Instance | InstanceAccountingSynchronisation
\ No newline at end of file
SlapOSAccountingSystemPreference
InstanceAccountingSynchronisation
SlapOSAccountingHostingSubscriptionConstraint
SlapOSAccountingSaleInvoiceTransactionConstraint
InstanceAccountingSynchronisation
\ No newline at end of file
SlapOSAccountingSalePackingListConstraint
SlapOSAccountingSystemPreference
\ No newline at end of file
......@@ -13,7 +13,6 @@ vifib_base
vifib_configurator
vifib_data
slapos_category
vifib_data_simulation
slapos_payzen
vifib_slap
vifib_slapos_accounting
......
576
\ No newline at end of file
577
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment