Esempio n. 1
0
 def test_from_user_to_user(self):
     # Test proper conversion of user-facing types from RDFlib types
     # through the Property interfaces after serializing and de-serializing
     doc = sbol.Document()
     cd = doc.componentDefinitions.create('cd')
     cd.int_property = sbol.IntProperty(cd, 'http://examples.org', '0', '1', None, 42)
     self.assertEqual(42, cd.int_property)
     doc2 = sbol.Document()
     doc2.readString(doc.writeString())
     cd2 = doc2.componentDefinitions['cd']
     cd2.int_property = sbol.IntProperty(cd, 'http://examples.org', '0', '1', None)
     self.assertEqual(42, cd2.int_property)
Esempio n. 2
0
 def test_six_arg_constructor_none(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testInt'
     initial_value = 32
     prop = sbol2.IntProperty(cd, type_uri, '0', '1', None, initial_value)
     self.assertEqual(initial_value, prop.value)
     self.assertEqual([], prop._validation_rules)
Esempio n. 3
0
 def test_five_arg_constructor_values(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testInt'
     initial_value = [1, 2, 3]
     prop = sbol2.IntProperty(cd, type_uri, '0', '*', initial_value)
     self.assertEqual(initial_value, prop.value)
     self.assertEqual([], prop._validation_rules)
Esempio n. 4
0
 def test_five_arg_constructor_validators(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testInt'
     validation_rules = [print]
     prop = sbol2.IntProperty(cd, type_uri, '0', '*', validation_rules)
     self.assertEqual([], prop.value)
     self.assertEqual(validation_rules, prop._validation_rules)
Esempio n. 5
0
 def test_init_store(self):
     # Ensure that property constructors initialize the parent
     # object's value store
     obj = sbol2.SBOLObject()
     type_uri = 'http://example.com#thing'
     obj.thing = sbol2.IntProperty(obj, type_uri, '0', '*')
     self.assertIn(type_uri, obj.properties)
     self.assertEqual([], obj.properties[type_uri])
     self.assertEqual([], obj.thing)
Esempio n. 6
0
 def test_four_arg_constructor(self):
     cd = sbol2.ComponentDefinition()
     type_uri = 'http://example.com/test#testInt'
     prop = sbol2.IntProperty(cd, type_uri, '0', '1')
     self.assertEqual(None, prop.value)
     self.assertEqual([], prop._validation_rules)