def test_bundles2(self): prov_document = examples.bundles2() stored_document_id = self.provapi.create_document_from_prov( prov_document) stored_document = self.provapi.get_document_as_prov(stored_document_id) self.assertEqual(stored_document, prov_document)
def test_get_document_as_prov(self): example = examples.bundles2() document_id = self.provapi.create_document_from_prov(example) prov_document = self.provapi.get_document_as_prov(document_id) self.assertIsNotNone(prov_document) self.assertIsInstance(prov_document, ProvDocument) self.assertEqual(prov_document, example)
def test_save_bundle(self): """ Test the public method to save bundles """ self.clear_database() doc = examples.bundles2() bundle = list(doc.bundles).pop() self.provapi.save_bundle(bundle)
def test_save_document_from_prov_bundles2(self): """ Try to create more bundles :return: """ self.clear_database() example = examples.bundles2() document_id = self.provapi.save_document_from_prov(example) self.assertIsNotNone(document_id) self.assertIsInstance(document_id, str)
def test_get_bundle(self): """ Test the public method to get bundles """ self.clear_database() doc = examples.bundles2() bundle = list(doc.bundles).pop() self.provapi.save_bundle(bundle) db_bundle = self.provapi.get_bundle(bundle.identifier) self.assertIsNotNone(db_bundle) self.assertIsInstance(db_bundle, ProvBundle) self.assertEqual(db_bundle, bundle)
def test_get_document_as_prov(self): """ Try to get the document as ProvDocument instnace :return: """ self.clear_database() example = examples.bundles2() document_id = self.provapi.save_document_from_prov(example) prov_document = self.provapi.get_document_as_prov(document_id) self.assertIsNotNone(prov_document) self.assertIsInstance(prov_document, ProvDocument) self.assertEqual(prov_document, example)
def test_bundles2(self): """ This test try to save and restore a common prov example document. With a bundle and some connections inside the bundle. This example is also available via `Provstore <https://provenance.ecs.soton.ac.uk/store/documents/114704/>` The main difference to the bundle_1 is that here we have also a mentionOf connection between bundles. See PROV-Links spec for more information :return: """ self.clear_database() prov_document = examples.bundles2() stored_document_id = self.provapi.save_document_from_prov( prov_document) stored_document = self.provapi.get_document_as_prov(stored_document_id) self.assertEqual(stored_document, prov_document)
def test_get_elements(self): """ Test for the get_elements function """ self.clear_database() doc = examples.bundles2() self.provapi.save_document(doc) activities = self.provapi.get_elements(ProvActivity) self.assertIsNotNone(activities) self.assertIsInstance(activities, ProvDocument) self.assertEqual(len(activities.get_records()), 0) # document contains only 4 unknown activities entities = self.provapi.get_elements(ProvEntity) self.assertIsNotNone(entities) self.assertIsInstance(entities, ProvDocument) self.assertEqual(len(entities.get_records()), 5) agents = self.provapi.get_elements(ProvAgent) self.assertIsNotNone(agents) self.assertIsInstance(agents, ProvDocument) self.assertEqual(len(agents.get_records()), 2)
def test_create_document_from_prov_bundles2(self): example = examples.bundles2() document_id = self.provapi.create_document_from_prov(example) self.assertIsNotNone(document_id) self.assertIsInstance(document_id, str)