Commit e44d69a2 authored by Łukasz Nowak's avatar Łukasz Nowak

Restore Computer constraint.

parent 0d4b57b5
......@@ -6,10 +6,32 @@
</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>VifibComputerConstraint</string> </value>
</item>
<item>
<key> <string>last_id</string> </key>
<value> <string>3</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Property Sheet</string> </value>
......@@ -17,4 +39,26 @@
</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="String Attribute Match 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>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>reference</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>reference_not_empty_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_match</string> </key>
<value> <string>Reference must be defined</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Reference must be defined</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Reference must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</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="Attribute Unicity 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_property</string> </key>
<value>
<tuple>
<string>reference</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>filter_parameter</string> </key>
<value> <string>python: {\'portal_type\': (object.getPortalType(), \'Person\'), \'reference\': object.getReference()}</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>reference_unicity_constraint</string> </value>
</item>
<item>
<key> <string>message_invalid_attribute_unicity</string> </key>
<value> <string>Reference must be unique</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Attribute Unicity Constraint</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="String Attribute Match 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>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>message_property_not_set</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>constraint_property</string> </key>
<value>
<tuple>
<string>title</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>title_not_empty_constraint</string> </value>
</item>
<item>
<key> <string>message_attribute_match</string> </key>
<value> <string>Title must be defined</string> </value>
</item>
<item>
<key> <string>message_no_such_property</string> </key>
<value> <string>Title must be defined</string> </value>
</item>
<item>
<key> <string>message_property_not_set</string> </key>
<value> <string>Title must be defined</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>String Attribute Match Constraint</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>
......@@ -84,3 +84,47 @@ class TestVifibAssignmentConstraint(testVifibMixin):
person.validate()
self.assertFalse(consistency_message in getMessageList(assignment))
class TestVifibComputerConstraint(testVifibMixin):
def getTitle(self):
return "Vifib Computer Constraint checks"
def test_title_not_empty(self):
computer = self.portal.computer_module.newContent(portal_type='Computer')
consistency_message = 'Title must be defined'
self.assertTrue(consistency_message in getMessageList(computer))
computer.setTitle(rndstr())
self.assertFalse(consistency_message in getMessageList(computer))
def test_reference_not_empty(self):
computer = self.portal.computer_module.newContent(portal_type='Computer')
consistency_message = 'Reference must be defined'
self.assertTrue(consistency_message in getMessageList(computer))
computer.setReference(rndstr())
self.assertFalse(consistency_message in getMessageList(computer))
def test_reference_unique(self):
reference = rndstr()
reference_2 = rndstr()
computer = self.portal.computer_module.newContent(portal_type='Computer',
reference=reference)
computer_2 = self.portal.computer_module.newContent(portal_type='Computer',
reference=reference)
consistency_message = 'Reference must be unique'
self.stepTic()
self.assertTrue(consistency_message in getMessageList(computer))
self.assertTrue(consistency_message in getMessageList(computer_2))
computer_2.setReference(reference_2)
self.stepTic()
self.assertFalse(consistency_message in getMessageList(computer))
self.assertFalse(consistency_message in getMessageList(computer_2))
193
\ No newline at end of file
194
\ 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