Ejemplo n.º 1
0
 def test_addImplementation(self):
     doc = sbol.Document()
     with self.assertRaises(Exception):
         # This raises an attribute exception right now, and that
         # should change in the future.
         doc.addImplementation('foo')
     impl = sbol.Implementation(uri='foo')
     doc.addImplementation(impl)
     self.assertEqual(doc.implementations[0], impl)
     impl2 = sbol.Implementation(uri='bar')
     impl3 = sbol.Implementation(uri='baz')
     doc.addImplementation([impl2, impl3])
     self.assertEqual(doc.implementations[1], impl2)
     self.assertEqual(doc.implementations[2], impl3)
Ejemplo n.º 2
0
 def test_getImplementation(self):
     homespace = 'http://sbols.org/sbol_test'
     sbol.setHomespace(homespace)
     doc = sbol.Document()
     impl = sbol.Implementation(uri='foo')
     doc.addImplementation(impl)
     impl2 = sbol.Implementation(uri='bar')
     doc.addImplementation(impl2)
     # Get by index
     self.assertEqual(doc.getImplementation(0), impl)
     self.assertEqual(doc.getImplementation(1), impl2)
     # Get by short URI
     self.assertEqual(doc.getImplementation('foo'), impl)
     self.assertEqual(doc.getImplementation('bar'), impl2)
     # Get by full URI
     uri_template = '{}/Implementation/{}/1'
     uri = rdflib.URIRef(uri_template.format(homespace, 'foo'))
     self.assertEqual(doc.getImplementation(uri), impl)
     uri = rdflib.URIRef(uri_template.format(homespace, 'bar'))
     self.assertEqual(doc.getImplementation(uri), impl2)
Ejemplo n.º 3
0
 def test2ArgConstructor(self):
     name = 'foo'
     version = '3'
     c = sbol.Implementation(name, version)
     expected_identity = self.make_identity(self.homespace, name, version)
     self.assertEqual(c.identity, expected_identity)
     self.assertEqual(c.displayId, name)
     self.assertEqual(c.version, version)
     self.assertEqual(c.rdf_type, sbol.SBOL_IMPLEMENTATION)
     doc = sbol.Document()
     doc.addImplementation(c)
     self.assertEqual(len(doc.implementations), 1)
Ejemplo n.º 4
0
 def testEmptyConstructor(self):
     # This is the default name in the implementation constructor
     name = 'example'
     c = sbol.Implementation()
     expected_identity = self.make_identity(self.homespace, name,
                                            sbol.VERSION_STRING)
     self.assertEqual(c.identity, expected_identity)
     self.assertEqual(c.displayId, name)
     self.assertEqual(c.version, sbol.VERSION_STRING)
     self.assertEqual(c.rdf_type, sbol.SBOL_IMPLEMENTATION)
     doc = sbol.Document()
     doc.addImplementation(c)
     self.assertEqual(len(doc.implementations), 1)
Ejemplo n.º 5
0
 def test3ArgConstructor(self):
     name = 'foo'
     version = '3'
     rdf_type = sbol.SBOL_IMPLEMENTATION + '2'
     c = sbol.Implementation(name, version, type_uri=rdf_type)
     expected_identity = self.make_identity(self.homespace, name, version,
                                            'Implementation2')
     self.assertEqual(c.identity, expected_identity)
     self.assertEqual(c.displayId, name)
     self.assertEqual(c.version, version)
     self.assertEqual(c.rdf_type, rdf_type)
     # Verify that when added to a document, this implementation is
     # not in the list of implementations. That's because the rdf_type
     # is not SBOL_IMPLEMENTATION.
     doc = sbol.Document()
     doc.addImplementation(c)
     self.assertEqual(len(doc.implementations), 0)
Ejemplo n.º 6
0
 def impl_gen(count):
     for i in range(count):
         uri = 'impl{}'.format(i)
         yield sbol.Implementation(uri=uri)