Commit 0ba2db63 authored by Łukasz Nowak's avatar Łukasz Nowak

Define constraint for consumption delivery line.

parent 487ccdb5
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</item> </item>
<item> <item>
<key> <string>constraint_portal_type</string> </key> <key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Computer Partition\', \'Slave Partition\')</string> </value> <value> <string>python: (\'Hosting Subscription\',)</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -38,19 +38,39 @@ ...@@ -38,19 +38,39 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>sale_packing_list_line_aggregate_computer_partition_constraint</string> </value> <value> <string>aggregate_hosting_subscription_constraint</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>max_arity</string> </key> <key> <string>max_arity</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
</item> </item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>message_arity_not_in_range</string> </key>
<value> <string>There should be one Hosting Subscription related</string> </value>
</item>
<item>
<key> <string>message_arity_too_small</string> </key>
<value> <string>There should be one Hosting Subscription related</string> </value>
</item>
<item> <item>
<key> <string>message_arity_with_portal_type_not_in_range</string> </key> <key> <string>message_arity_with_portal_type_not_in_range</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value> <value> <string>There should be one Hosting Subscription related</string> </value>
</item> </item>
<item> <item>
<key> <string>message_arity_with_portal_type_too_small</string> </key> <key> <string>message_arity_with_portal_type_too_small</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value> <value> <string>There should be one Hosting Subscription related</string> </value>
</item> </item>
<item> <item>
<key> <string>min_arity</string> </key> <key> <string>min_arity</string> </key>
...@@ -60,9 +80,21 @@ ...@@ -60,9 +80,21 @@
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Category Membership Arity Constraint</string> </value> <value> <string>Category Membership Arity Constraint</string> </value>
</item> </item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>test_tales_expression</string> </key> <key> <string>test_tales_expression</string> </key>
<value> <string>python: object.getResourceValue() is not None and object.getResource() in [object.portal_preferences.getPreferredInstanceSetupResource(), object.portal_preferences.getPreferredInstanceHostingResource(), object.portal_preferences.getPreferredInstanceCleanupResource()]</string> </value> <value> <string>python: object.getSpecialise() == \'sale_trade_condition_module/slapos_consumption_trade_condition\'</string> </value>
</item> </item>
<item> <item>
<key> <string>use_acquisition</string> </key> <key> <string>use_acquisition</string> </key>
......
...@@ -38,19 +38,39 @@ ...@@ -38,19 +38,39 @@
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>sale_packing_list_line_aggregate_software_instance_constraint</string> </value> <value> <string>aggregate_software_instance_constraint</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item> </item>
<item> <item>
<key> <string>max_arity</string> </key> <key> <string>max_arity</string> </key>
<value> <int>1</int> </value> <value> <int>1</int> </value>
</item> </item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>message_arity_not_in_range</string> </key>
<value> <string>There should be one Software or Slave Instance related</string> </value>
</item>
<item>
<key> <string>message_arity_too_small</string> </key>
<value> <string>There should be one Software or Slave Instance related</string> </value>
</item>
<item> <item>
<key> <string>message_arity_with_portal_type_not_in_range</string> </key> <key> <string>message_arity_with_portal_type_not_in_range</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value> <value> <string>There should be one Software or Slave Instance related</string> </value>
</item> </item>
<item> <item>
<key> <string>message_arity_with_portal_type_too_small</string> </key> <key> <string>message_arity_with_portal_type_too_small</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value> <value> <string>There should be one Software or Slave Instance related</string> </value>
</item> </item>
<item> <item>
<key> <string>min_arity</string> </key> <key> <string>min_arity</string> </key>
...@@ -60,9 +80,21 @@ ...@@ -60,9 +80,21 @@
<key> <string>portal_type</string> </key> <key> <string>portal_type</string> </key>
<value> <string>Category Membership Arity Constraint</string> </value> <value> <string>Category Membership Arity Constraint</string> </value>
</item> </item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item> <item>
<key> <string>test_tales_expression</string> </key> <key> <string>test_tales_expression</string> </key>
<value> <string>python: object.getResourceValue() is not None and object.getResource() in [object.portal_preferences.getPreferredInstanceSetupResource(), object.portal_preferences.getPreferredInstanceHostingResource(), object.portal_preferences.getPreferredInstanceCleanupResource()]</string> </value> <value> <string>python: object.getSpecialise() == \'sale_trade_condition_module/slapos_consumption_trade_condition\'</string> </value>
</item> </item>
<item> <item>
<key> <string>use_acquisition</string> </key> <key> <string>use_acquisition</string> </key>
......
...@@ -358,6 +358,7 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin): ...@@ -358,6 +358,7 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin):
self.assertFalse(message_price in self.getMessageList(delivery_line)) self.assertFalse(message_price in self.getMessageList(delivery_line))
self.assertFalse(message_quantity in self.getMessageList(delivery_line)) self.assertFalse(message_quantity in self.getMessageList(delivery_line))
@withAbort
def test_resource_arity(self): def test_resource_arity(self):
category = 'resource' category = 'resource'
message = "Arity Error for Relation ['%s'], arity is equal to "\ message = "Arity Error for Relation ['%s'], arity is equal to "\
...@@ -383,3 +384,42 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin): ...@@ -383,3 +384,42 @@ class TestSalePackingListLine(TestSlapOSConstraintMixin):
delivery_line.edit(**{key: [service_1]}) delivery_line.edit(**{key: [service_1]})
self.assertFalse(message in self.getMessageList(delivery_line)) self.assertFalse(message in self.getMessageList(delivery_line))
self.assertFalse(message_2 in self.getMessageList(delivery_line)) self.assertFalse(message_2 in self.getMessageList(delivery_line))
@withAbort
def _test_aggregate(self, message, aggregate_1, aggregate_2):
category = 'aggregate'
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
delivery_line = delivery.newContent(portal_type='Sale Packing List Line')
product = self.portal.product_module.newContent(
portal_type='Product').getRelativeUrl()
key = '%s_list' % category
self.assertFalse(message in self.getMessageList(delivery_line))
delivery.edit(specialise='sale_trade_condition_module/slapos_consumption_trade_condition')
self.assertTrue(message in self.getMessageList(delivery_line))
delivery_line.edit(**{key: [product]})
self.assertTrue(message in self.getMessageList(delivery_line))
delivery_line.edit(**{key: [aggregate_1, aggregate_2]})
self.assertTrue(message in self.getMessageList(delivery_line))
delivery_line.edit(**{key: [aggregate_1]})
self.assertFalse(message in self.getMessageList(delivery_line))
def test_aggregate_hosting_subscription(self):
self._test_aggregate("There should be one Hosting Subscription related",
self.portal.hosting_subscription_module.newContent(
portal_type='Hosting Subscription').getRelativeUrl(),
self.portal.hosting_subscription_module.newContent(
portal_type='Hosting Subscription').getRelativeUrl())
def test_aggregate_software_instance(self):
self._test_aggregate("There should be one Software or Slave Instance related",
self.portal.software_instance_module.newContent(
portal_type='Software Instance').getRelativeUrl(),
self.portal.software_instance_module.newContent(
portal_type='Software Instance').getRelativeUrl())
self._test_aggregate("There should be one Software or Slave Instance related",
self.portal.software_instance_module.newContent(
portal_type='Slave Instance').getRelativeUrl(),
self.portal.software_instance_module.newContent(
portal_type='Slave Instance').getRelativeUrl())
192 193
\ No newline at end of file \ No newline at end of file
...@@ -11,7 +11,4 @@ ...@@ -11,7 +11,4 @@
<portal_type id="Sale Packing List"> <portal_type id="Sale Packing List">
<item>VifibSalePackingListConstraint</item> <item>VifibSalePackingListConstraint</item>
</portal_type> </portal_type>
<portal_type id="Sale Packing List Line">
<item>VifibSalePackingListLineConstraint</item>
</portal_type>
</property_sheet_list> </property_sheet_list>
\ No newline at end of file
<?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>id</string> </key>
<value> <string>VifibSalePackingListLineConstraint</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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Attribute Equality Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_attribute_name</string> </key>
<value> <string>quantity</string> </value>
</item>
<item>
<key> <string>constraint_attribute_value</string> </key>
<value> <string>python: 1.0</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>quantity_value_constraint</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Attribute Equality Constraint</string> </value>
</item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>test_tales_expression</string> </key>
<value> <string>python: context.getSimulationState() != \'cancelled\' and context.getSpecialise() != \'sale_trade_condition_module/vifib_simple_trade_condition\'</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Membership Arity Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>aggregate</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: \'Hosting Subscription\'</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sale_packing_list_line_aggregate_hosting_subscription_constraint</string> </value>
</item>
<item>
<key> <string>max_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_not_in_range</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_too_small</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value>
</item>
<item>
<key> <string>min_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Membership Arity Constraint</string> </value>
</item>
<item>
<key> <string>test_tales_expression</string> </key>
<value> <string>python: object.getResourceValue() is not None and object.getResource() in [object.portal_preferences.getPreferredInstanceSetupResource(), object.portal_preferences.getPreferredInstanceHostingResource(), object.portal_preferences.getPreferredInstanceCleanupResource()]</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Membership Arity Constraint" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>constraint_base_category</string> </key>
<value>
<tuple>
<string>aggregate</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: \'Software Release\'</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sale_packing_list_line_aggregate_software_release_constraint</string> </value>
</item>
<item>
<key> <string>max_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_not_in_range</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value>
</item>
<item>
<key> <string>message_arity_with_portal_type_too_small</string> </key>
<value> <string>There should be exactly one ${portal_type} present in Items</string> </value>
</item>
<item>
<key> <string>min_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category Membership Arity Constraint</string> </value>
</item>
<item>
<key> <string>test_tales_expression</string> </key>
<value> <string>python: object.getResourceValue() is not None and object.getResource() in [object.portal_preferences.getPreferredInstanceSetupResource(), object.portal_preferences.getPreferredInstanceHostingResource(), object.portal_preferences.getPreferredInstanceCleanupResource()]</string> </value>
</item>
<item>
<key> <string>use_acquisition</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
579 580
\ No newline at end of file \ No newline at end of file
Open Sale Order Line | VifibOpenSaleOrderLineConstraint Open Sale Order Line | VifibOpenSaleOrderLineConstraint
Open Sale Order | VifibOpenSaleOrderConstraint Open Sale Order | VifibOpenSaleOrderConstraint
Person | VifibPersonConstraint Person | VifibPersonConstraint
Sale Packing List Line | VifibSalePackingListLineConstraint
Sale Packing List | VifibSalePackingListConstraint Sale Packing List | VifibSalePackingListConstraint
\ No newline at end of file
VifibSalePackingListLineConstraint
VifibSalePackingListConstraint VifibSalePackingListConstraint
VifibOpenSaleOrderLineConstraint VifibOpenSaleOrderLineConstraint
VifibOpenSaleOrderConstraint VifibOpenSaleOrderConstraint
......
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