Commit 376d52e9 authored by Łukasz Nowak's avatar Łukasz Nowak

Extend Computer Partition constraints.

Busy computer partition shall have exactly one related Software Instance, but
might have any related Slaves.
parent 79d6924c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Related Membership Arity 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_base_category</string> </key>
<value>
<tuple>
<string>default_aggregate</string>
</tuple>
</value>
</item>
<item>
<key> <string>constraint_portal_type</string> </key>
<value> <string>python: (\'Software Instance\',)</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Computer Partition which is busy, shall have one aggregate related instance.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>busy_partition_has_one_related_instance_constraint</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>max_arity</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</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 Related Membership Arity 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.getSlapState() == \'busy\'</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>
......@@ -83,6 +83,58 @@ class TestSlapOSComputerPartitionConstraint(TestSlapOSConstraintMixin):
self.assertFalse(consistency_message in self.getMessageList(partition))
self.portal.portal_workflow._jumpToStateFor(partition, 'free')
def test_busy_partition_has_one_related_instance(self):
computer = self.portal.computer_module.template_computer\
.Base_createCloneDocument(batch_mode=1)
partition = computer.newContent(portal_type='Computer Partition')
self.portal.portal_workflow._jumpToStateFor(partition, 'busy')
software_instance = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
software_instance.edit(aggregate=partition.getRelativeUrl())
software_instance_2 = self.portal.software_instance_module\
.template_software_instance.Base_createCloneDocument(batch_mode=1)
slave_instance = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
slave_instance_2 = self.portal.software_instance_module.newContent(
portal_type='Slave Instance')
partition.immediateReindexObject()
software_instance.immediateReindexObject()
software_instance_2.immediateReindexObject()
slave_instance.immediateReindexObject()
slave_instance_2.immediateReindexObject()
consistency_message = "Arity Error for Relation ['default_aggregate'], " \
"arity is equal to 0 but should be between 1 and 1"
# test the test: no expected message found
current_message_list = self.getMessageList(partition)
self.assertFalse(consistency_message in current_message_list)
# check case for Software Instance
software_instance.edit(aggregate=None)
software_instance.immediateReindexObject()
self.assertTrue(consistency_message in self.getMessageList(partition))
# check case for many Software Instance
software_instance.edit(aggregate=partition.getRelativeUrl())
software_instance_2.edit(aggregate=partition.getRelativeUrl())
software_instance.immediateReindexObject()
software_instance_2.immediateReindexObject()
consistency_message_2 = "Arity Error for Relation ['default_aggregate'], " \
"arity is equal to 2 but should be between 1 and 1"
self.assertTrue(consistency_message_2 in self.getMessageList(partition))
# check case for many Slave Instane
software_instance_2.edit(aggregate=None)
software_instance_2.immediateReindexObject()
slave_instance.edit(aggregate=partition.getRelativeUrl())
slave_instance_2.edit(aggregate=partition.getRelativeUrl())
slave_instance.immediateReindexObject()
slave_instance_2.immediateReindexObject()
self.assertFalse(consistency_message in self.getMessageList(partition))
self.assertFalse(consistency_message_2 in self.getMessageList(partition))
class TestSlapOSSoftwareInstanceConstraint(TestSlapOSConstraintMixin):
def afterSetUp(self):
self.software_instance = self.portal.software_instance_module.newContent(
......
261
\ No newline at end of file
262
\ 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