Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/prov/tests/qnames.py @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 from __future__ import (absolute_import, division, print_function, | |
| 2 unicode_literals) | |
| 3 | |
| 4 from prov.model import ProvDocument, Namespace | |
| 5 | |
| 6 | |
| 7 def document_with_n_bundles_having_default_namespace(n): | |
| 8 prov_doc = ProvDocument() | |
| 9 prov_doc.add_namespace('ex', 'http://www.example.org/') | |
| 10 for i in range(n): | |
| 11 x = str(i + 1) | |
| 12 bundle = prov_doc.bundle('ex:bundle/' + x) | |
| 13 bundle.set_default_namespace('http://www.example.org/default/' + x) | |
| 14 bundle.entity('e') | |
| 15 return prov_doc | |
| 16 | |
| 17 | |
| 18 class TestQualifiedNamesBase(object): | |
| 19 """This is the base class for testing support for qualified names and | |
| 20 namespaces. It is not runnable and needs to be included in a subclass of | |
| 21 RoundTripTestCase. | |
| 22 """ | |
| 23 | |
| 24 def test_namespace_inheritance(self): | |
| 25 prov_doc = ProvDocument() | |
| 26 prov_doc.add_namespace('ex', 'http://www.example.org/') | |
| 27 bundle = prov_doc.bundle('ex:bundle') | |
| 28 e1 = bundle.entity('ex:e1') | |
| 29 self.assertIsNotNone(e1.identifier, "e1's identifier is None!") | |
| 30 self.do_tests(prov_doc) | |
| 31 | |
| 32 def test_default_namespace_inheritance(self): | |
| 33 prov_doc = ProvDocument() | |
| 34 prov_doc.set_default_namespace('http://www.example.org/') | |
| 35 bundle = prov_doc.bundle('bundle') | |
| 36 e1 = bundle.entity('e1') | |
| 37 self.assertIsNotNone(e1.identifier, "e1's identifier is None!") | |
| 38 self.do_tests(prov_doc) | |
| 39 | |
| 40 def test_flattening_1_bundle_with_default_namespace(self): | |
| 41 prov_doc = document_with_n_bundles_having_default_namespace(1) | |
| 42 flattened = prov_doc.flattened() | |
| 43 self.do_tests(flattened) | |
| 44 | |
| 45 def test_flattening_2_bundles_with_default_namespace(self): | |
| 46 prov_doc = document_with_n_bundles_having_default_namespace(2) | |
| 47 flattened = prov_doc.flattened() | |
| 48 self.do_tests(flattened) | |
| 49 | |
| 50 def test_flattening_3_bundles_with_default_namespace(self): | |
| 51 prov_doc = document_with_n_bundles_having_default_namespace(3) | |
| 52 flattened = prov_doc.flattened() | |
| 53 self.do_tests(flattened) | |
| 54 | |
| 55 def test_flattening_1_bundle_with_default_namespaces(self): | |
| 56 prov_doc = document_with_n_bundles_having_default_namespace(1) | |
| 57 prov_doc.set_default_namespace('http://www.example.org/default/0') | |
| 58 flattened = prov_doc.flattened() | |
| 59 self.do_tests(flattened) | |
| 60 | |
| 61 def test_flattening_2_bundle_with_default_namespaces(self): | |
| 62 prov_doc = document_with_n_bundles_having_default_namespace(2) | |
| 63 prov_doc.set_default_namespace('http://www.example.org/default/0') | |
| 64 flattened = prov_doc.flattened() | |
| 65 self.do_tests(flattened) |
