comparison env/lib/python3.9/site-packages/prov/tests/attributes.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
1 from __future__ import (absolute_import, division, print_function,
2 unicode_literals)
3
4 from prov.model import *
5
6
7 EX_NS = Namespace('ex', 'http://example.org/')
8 EX_OTHER_NS = Namespace('other', 'http://example.org/')
9
10
11 class TestAttributesBase(object):
12 """This is the base class for testing support for various datatypes.
13 It is not runnable and needs to be included in a subclass of
14 RoundTripTestCase.
15 """
16
17 attribute_values = [
18 "un lieu",
19 Literal("un lieu", langtag='fr'),
20 Literal("a place", langtag='en'),
21 Literal(1, XSD_INT),
22 Literal(1, XSD_LONG),
23 Literal(1, XSD_SHORT),
24 Literal(2.0, XSD_DOUBLE),
25 Literal(1.0, XSD_FLOAT),
26 Literal(10, XSD_DECIMAL),
27 True,
28 False,
29 Literal(10, XSD_BYTE),
30 Literal(10, XSD_UNSIGNEDINT),
31 Literal(10, XSD_UNSIGNEDLONG),
32 Literal(10, XSD_INTEGER),
33 Literal(10, XSD_UNSIGNEDSHORT),
34 Literal(10, XSD_NONNEGATIVEINTEGER),
35 Literal(-10, XSD_NONPOSITIVEINTEGER),
36 Literal(10, XSD_POSITIVEINTEGER),
37 Literal(10, XSD_UNSIGNEDBYTE),
38 Identifier('http://example.org'),
39 Literal('http://example.org', XSD_ANYURI),
40 EX_NS['abc'],
41 EX_OTHER_NS['abcd'],
42 Namespace('ex', 'http://example4.org/')['zabc'],
43 Namespace('other', 'http://example4.org/')['zabcd'],
44
45 datetime.datetime.now(),
46 Literal(datetime.datetime.now().isoformat(), XSD_DATETIME)
47 ]
48
49 def new_document(self):
50 return ProvDocument()
51
52 def run_entity_with_one_type_attribute(self, n):
53 document = self.new_document()
54 document.entity(
55 EX_NS['et%d' % n], {'prov:type': self.attribute_values[n]}
56 )
57 self.do_tests(document)
58
59 def test_entity_with_one_type_attribute_0(self):
60 self.run_entity_with_one_type_attribute(0)
61
62 def test_entity_with_one_type_attribute_1(self):
63 self.run_entity_with_one_type_attribute(1)
64
65 def test_entity_with_one_type_attribute_2(self):
66 self.run_entity_with_one_type_attribute(2)
67
68 def test_entity_with_one_type_attribute_3(self):
69 self.run_entity_with_one_type_attribute(3)
70
71 def test_entity_with_one_type_attribute_4(self):
72 self.run_entity_with_one_type_attribute(4)
73
74 def test_entity_with_one_type_attribute_5(self):
75 self.run_entity_with_one_type_attribute(5)
76
77 def test_entity_with_one_type_attribute_6(self):
78 self.run_entity_with_one_type_attribute(6)
79
80 def test_entity_with_one_type_attribute_7(self):
81 self.run_entity_with_one_type_attribute(7)
82
83 def test_entity_with_one_type_attribute_8(self):
84 self.run_entity_with_one_type_attribute(8)
85
86 def test_entity_with_one_type_attribute_9(self):
87 self.run_entity_with_one_type_attribute(9)
88
89 def test_entity_with_one_type_attribute_10(self):
90 self.run_entity_with_one_type_attribute(10)
91
92 def test_entity_with_one_type_attribute_11(self):
93 self.run_entity_with_one_type_attribute(11)
94
95 def test_entity_with_one_type_attribute_12(self):
96 self.run_entity_with_one_type_attribute(12)
97
98 def test_entity_with_one_type_attribute_13(self):
99 self.run_entity_with_one_type_attribute(13)
100
101 def test_entity_with_one_type_attribute_14(self):
102 self.run_entity_with_one_type_attribute(14)
103
104 def test_entity_with_one_type_attribute_15(self):
105 self.run_entity_with_one_type_attribute(15)
106
107 def test_entity_with_one_type_attribute_16(self):
108 self.run_entity_with_one_type_attribute(16)
109
110 def test_entity_with_one_type_attribute_17(self):
111 self.run_entity_with_one_type_attribute(17)
112
113 def test_entity_with_one_type_attribute_18(self):
114 self.run_entity_with_one_type_attribute(18)
115
116 def test_entity_with_one_type_attribute_19(self):
117 self.run_entity_with_one_type_attribute(19)
118
119 def test_entity_with_one_type_attribute_20(self):
120 self.run_entity_with_one_type_attribute(20)
121
122 def test_entity_with_one_type_attribute_21(self):
123 self.run_entity_with_one_type_attribute(21)
124
125 def test_entity_with_one_type_attribute_22(self):
126 self.run_entity_with_one_type_attribute(22)
127
128 def test_entity_with_one_type_attribute_23(self):
129 self.run_entity_with_one_type_attribute(23)
130
131 def test_entity_with_one_type_attribute_24(self):
132 self.run_entity_with_one_type_attribute(24)
133
134 def test_entity_with_one_type_attribute_25(self):
135 self.run_entity_with_one_type_attribute(25)
136
137 def test_entity_with_one_type_attribute_26(self):
138 self.run_entity_with_one_type_attribute(26)
139
140 def test_entity_with_one_type_attribute_27(self):
141 self.run_entity_with_one_type_attribute(27)
142
143 def test_entity_with_multiple_attribute(self):
144 document = self.new_document()
145 attributes = [
146 (EX_NS['v_%d' % i], value)
147 for i, value in enumerate(self.attribute_values)
148 ]
149 document.entity(EX_NS['emov'], attributes)
150 self.do_tests(document)
151
152 def test_entity_with_multiple_value_attribute(self):
153 document = self.new_document()
154 attributes = [
155 ('prov:value', value)
156 for i, value in enumerate(self.attribute_values)
157 ]
158 document.entity(EX_NS['emv'], attributes)
159 self.do_tests(document)