def bundles2(): # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles2.provn # =========================================================================== # document g = ProvBundle() # prefix ex <http://example.org/example/> g.add_namespace("ex", "http://www.example.com/") # prefix alice <http://example.org/alice/> # prefix bob <http://example.org/bob/> g.add_namespace("alice", "http://example.org/alice/") g.add_namespace("bob", "http://example.org/bob/") # entity(bob:bundle4, [prov:type='prov:Bundle']) # wasGeneratedBy(bob:bundle4, -, 2012-05-24T10:30:00) # agent(ex:Bob) # wasAttributedTo(bob:bundle4, ex:Bob) g.entity("bob:bundle4", {"prov:type": PROV["Bundle"]}) g.wasGeneratedBy("bob:bundle4", time="2012-05-24T10:30:00") g.agent("ex:Bob") g.wasAttributedTo("bob:bundle4", "ex:Bob") # entity(alice:bundle5, [ prov:type='prov:Bundle' ]) # wasGeneratedBy(alice:bundle5, -, 2012-05-25T11:15:00) # agent(ex:Alice) # wasAttributedTo(alice:bundle5, ex:Alice) g.entity("alice:bundle5", {"prov:type": PROV["Bundle"]}) g.wasGeneratedBy("alice:bundle5", time="2012-05-25T11:15:00") g.agent("ex:Alice") g.wasAttributedTo("alice:bundle5", "ex:Alice") # bundle bob:bundle4 # entity(ex:report1, [ prov:type="report", ex:version=1 ]) # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) # endBundle b4 = g.bundle("bob:bundle4") b4.entity("ex:report1", {"prov:type": "report", "ex:version": 1}) b4.wasGeneratedBy("ex:report1", time="2012-05-24T10:00:01") # bundle alice:bundle5 # entity(ex:report1bis) # mentionOf(ex:report1bis, ex:report1, bob:bundle4) # entity(ex:report2, [ prov:type="report", ex:version=2 ]) # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) # wasDerivedFrom(ex:report2, ex:report1bis) # endBundle b5 = g.bundle("alice:bundle5") b5.entity("ex:report1bis") b5.mentionOf("ex:report1bis", "ex:report1", "bob:bundle4") b5.entity("ex:report2", [("prov:type", "report"), ("ex:version", 2)]) b5.wasGeneratedBy("ex:report2", time="2012-05-25T11:00:01") b5.wasDerivedFrom("ex:report2", "ex:report1bis") # endDocument return g
def bundles2(): # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles2.provn #=========================================================================== # document g = ProvBundle() # prefix ex <http://example.org/example/> g.add_namespace("ex", "http://www.example.com/") # prefix alice <http://example.org/alice/> # prefix bob <http://example.org/bob/> g.add_namespace('alice', 'http://example.org/alice/') g.add_namespace('bob', 'http://example.org/bob/') # entity(bob:bundle4, [prov:type='prov:Bundle']) # wasGeneratedBy(bob:bundle4, -, 2012-05-24T10:30:00) # agent(ex:Bob) # wasAttributedTo(bob:bundle4, ex:Bob) g.entity('bob:bundle4', {'prov:type': PROV['Bundle']}) g.wasGeneratedBy('bob:bundle4', time='2012-05-24T10:30:00') g.agent('ex:Bob') g.wasAttributedTo('bob:bundle4', 'ex:Bob') # entity(alice:bundle5, [ prov:type='prov:Bundle' ]) # wasGeneratedBy(alice:bundle5, -, 2012-05-25T11:15:00) # agent(ex:Alice) # wasAttributedTo(alice:bundle5, ex:Alice) g.entity('alice:bundle5', {'prov:type': PROV['Bundle']}) g.wasGeneratedBy('alice:bundle5', time='2012-05-25T11:15:00') g.agent('ex:Alice') g.wasAttributedTo('alice:bundle5', 'ex:Alice') # bundle bob:bundle4 # entity(ex:report1, [ prov:type="report", ex:version=1 ]) # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) # endBundle b4 = g.bundle('bob:bundle4') b4.entity('ex:report1', {'prov:type': "report", 'ex:version': 1}) b4.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01') # bundle alice:bundle5 # entity(ex:report1bis) # mentionOf(ex:report1bis, ex:report1, bob:bundle4) # entity(ex:report2, [ prov:type="report", ex:version=2 ]) # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) # wasDerivedFrom(ex:report2, ex:report1bis) # endBundle b5 = g.bundle('alice:bundle5') b5.entity('ex:report1bis') b5.mentionOf('ex:report1bis', 'ex:report1', 'bob:bundle4') b5.entity('ex:report2', [('prov:type', "report"), ('ex:version', 2)]) b5.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01') b5.wasDerivedFrom('ex:report2', 'ex:report1bis') # endDocument return g
def bundles1(): # https://github.com/lucmoreau/ProvToolbox/blob/master/prov-n/src/test/resources/prov/bundles1.provn # =============================================================================== # document g = ProvBundle() # prefix ex <http://example.org/example/> EX = Namespace("ex", "http://www.example.com/") g.add_namespace(EX) # prefix alice <http://example.org/alice/> # prefix bob <http://example.org/bob/> g.add_namespace("alice", "http://example.org/alice/") g.add_namespace("bob", "http://example.org/bob/") # entity(bob:bundle1, [prov:type='prov:Bundle']) g.entity("bob:bundle1", {"prov:type": PROV["Bundle"]}) # wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00) g.wasGeneratedBy("bob:bundle1", time="2012-05-24T10:30:00") # agent(ex:Bob) g.agent("ex:Bob") # wasAttributedTo(bob:bundle1, ex:Bob) g.wasAttributedTo("bob:bundle1", "ex:Bob") # entity(alice:bundle2, [ prov:type='prov:Bundle' ]) g.entity("alice:bundle2", {"prov:type": PROV["Bundle"]}) # wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00) g.wasGeneratedBy("alice:bundle2", time="2012-05-25T11:15:00") # agent(ex:Alice) g.agent("ex:Alice") # wasAttributedTo(alice:bundle2, ex:Alice) g.wasAttributedTo("alice:bundle2", "ex:Alice") # bundle bob:bundle1 b1 = g.bundle("bob:bundle1") # entity(ex:report1, [ prov:type="report", ex:version=1 ]) b1.entity("ex:report1", {"prov:type": "report", "ex:version": 1}) # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) b1.wasGeneratedBy("ex:report1", time="2012-05-24T10:00:01") # endBundle # bundle alice:bundle2 b2 = g.bundle("alice:bundle2") # entity(ex:report1) b2.entity("ex:report1") # entity(ex:report2, [ prov:type="report", ex:version=2 ]) b2.entity("ex:report2", {"prov:type": "report", "ex:version": 2}) # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) b2.wasGeneratedBy("ex:report2", time="2012-05-25T11:00:01") # wasDerivedFrom(ex:report2, ex:report1) b2.wasDerivedFrom("ex:report2", "ex:report1") # endBundle # endDocument return g
def test_inferred_retyping_in_flattened_documents(self): g = ProvBundle() g.add_namespace("ex", "http://www.example.com/") g.wasGeneratedBy('ex:Bob', time='2012-05-25T11:15:00') b1 = g.bundle('ex:bundle') b1.agent('ex:Bob') h = ProvBundle() h.add_namespace("ex", "http://www.example.com/") h.agent('ex:Bob') h.wasGeneratedBy('ex:Bob', time='2012-05-25T11:15:00') self.assertEqual(g.get_flattened(), h)
def test_non_unifiable_document(self): g = ProvBundle() g.add_namespace("ex", "http://www.example.com/") g.activity('ex:compose', other_attributes={'prov:role': "ex:dataToCompose1"}) g.used('ex:compose', 'ex:testEntity') with self.assertRaises(ProvExceptionCannotUnifyAttribute): g.activity('ex:testEntity') h = g.bundle('ex:bundle') h.add_namespace("ex", "http://www.example.com/") h.entity('ex:compose', other_attributes={'prov:label': "impossible!!!"}) with self.assertRaises(ProvExceptionCannotUnifyAttribute): g.get_flattened()
def bundles1(): # https://github.com/lucmoreau/ProvToolbox/blob/master/asn/src/test/resources/prov/bundles1.provn #=============================================================================== # bundle # # prefix ex <http://example.org/example/> # # prefix alice <http://example.org/alice/> # prefix bob <http://example.org/bob/> # # entity(bob:bundle1, [prov:type='prov:Bundle']) # wasGeneratedBy(bob:bundle1, -, 2012-05-24T10:30:00) # agent(ex:Bob) # wasAttributedTo(bob:bundle1, ex:Bob) # # entity(alice:bundle2, [ prov:type='prov:Bundle' ]) # wasGeneratedBy(alice:bundle2, -, 2012-05-25T11:15:00) # agent(ex:Alice) # wasAttributedTo(alice:bundle2, ex:Alice) # # bundle bob:bundle1 # entity(ex:report1, [ prov:type="report", ex:version=1 ]) # wasGeneratedBy(ex:report1, -, 2012-05-24T10:00:01) # endBundle # # bundle alice:bundle2 # entity(ex:report1) # entity(ex:report2, [ prov:type="report", ex:version=2 ]) # wasGeneratedBy(ex:report2, -, 2012-05-25T11:00:01) # wasDerivedFrom(ex:report2, ex:report1) # endBundle # # endBundle #=============================================================================== EX = Namespace("ex","http://www.example.com/") g = ProvBundle() g.add_namespace(EX) g.add_namespace('alice', 'http://example.org/alice/') g.add_namespace('bob', 'http://example.org/bob/') g.entity('bob:bundle1', {'prov:type': PROV['Bundle']}) g.wasGeneratedBy('bob:bundle1', time='2012-05-24T10:30:00') g.agent('ex:Bob') g.wasAttributedTo('bob:bundle1', 'ex:Bob') g.entity('alice:bundle2', {'prov:type': PROV['Bundle']}) g.wasGeneratedBy('alice:bundle2', time='2012-05-25T11:15:00') g.agent('ex:Alice') g.wasAttributedTo('alice:bundle2', 'ex:Alice') b1 = g.bundle('bob:bundle1') b1.entity('ex:report1', {'prov:type': "report", 'ex:version': 1}) b1.wasGeneratedBy('ex:report1', time='2012-05-24T10:00:01') b2 = g.bundle('alice:bundle2') b2.entity('ex:report1') b2.entity('ex:report2', {'prov:type': "report", 'ex:version': 2}) b2.wasGeneratedBy('ex:report2', time='2012-05-25T11:00:01') b2.wasDerivedFrom('ex:report2', 'ex:report1') return g