soia-client 1.0.1__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of soia-client might be problematic. Click here for more details.
- {soia_client-1.0.1 → soia_client-1.0.3}/PKG-INFO +2 -3
- {soia_client-1.0.1 → soia_client-1.0.3}/pyproject.toml +3 -3
- {soia_client-1.0.1 → soia_client-1.0.3}/soia_client.egg-info/PKG-INFO +2 -3
- soia_client-1.0.3/soialib/__init__.py +5 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/module_initializer.py +3 -3
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/serializer.py +1 -2
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/spec.py +0 -5
- {soia_client-1.0.1 → soia_client-1.0.3}/tests/test_module_initializer.py +248 -250
- soia_client-1.0.1/soialib/impl/__init__.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/LICENSE +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/README +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/setup.cfg +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soia_client.egg-info/SOURCES.txt +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soia_client.egg-info/dependency_links.txt +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soia_client.egg-info/top_level.txt +0 -0
- {soia_client-1.0.1/soialib → soia_client-1.0.3/soialib/impl}/__init__.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/arrays.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/encoding.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/enums.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/function_maker.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/optionals.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/primitives.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/repr.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/structs.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/impl/type_adapter.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/keyed_items.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/never.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/soialib/timestamp.py +0 -0
- {soia_client-1.0.1 → soia_client-1.0.3}/tests/test_timestamp.py +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: soia-client
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary: Read the latest Real Python tutorials
|
|
3
|
+
Version: 1.0.3
|
|
5
4
|
Author-email: Tyler Fibonacci <gepheum@gmail.com>
|
|
6
5
|
License: MIT License
|
|
7
6
|
|
|
@@ -25,7 +24,7 @@ License: MIT License
|
|
|
25
24
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
25
|
SOFTWARE.
|
|
27
26
|
|
|
28
|
-
Project-URL: Homepage, https://github.com/
|
|
27
|
+
Project-URL: Homepage, https://github.com/gepheum/soia-python-client
|
|
29
28
|
Classifier: License :: OSI Approved :: MIT License
|
|
30
29
|
Classifier: Programming Language :: Python
|
|
31
30
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "soia-client"
|
|
7
|
-
version = "1.0.
|
|
8
|
-
description = "
|
|
7
|
+
version = "1.0.3"
|
|
8
|
+
description = ""
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Tyler Fibonacci", email = "gepheum@gmail.com" }]
|
|
11
11
|
license = { file = "LICENSE" }
|
|
@@ -19,4 +19,4 @@ dependencies = []
|
|
|
19
19
|
requires-python = ">=3.10"
|
|
20
20
|
|
|
21
21
|
[project.urls]
|
|
22
|
-
Homepage = "https://github.com/
|
|
22
|
+
Homepage = "https://github.com/gepheum/soia-python-client"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: soia-client
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary: Read the latest Real Python tutorials
|
|
3
|
+
Version: 1.0.3
|
|
5
4
|
Author-email: Tyler Fibonacci <gepheum@gmail.com>
|
|
6
5
|
License: MIT License
|
|
7
6
|
|
|
@@ -25,7 +24,7 @@ License: MIT License
|
|
|
25
24
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
25
|
SOFTWARE.
|
|
27
26
|
|
|
28
|
-
Project-URL: Homepage, https://github.com/
|
|
27
|
+
Project-URL: Homepage, https://github.com/gepheum/soia-python-client
|
|
29
28
|
Classifier: License :: OSI Approved :: MIT License
|
|
30
29
|
Classifier: Programming Language :: Python
|
|
31
30
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -11,8 +11,8 @@ RecordAdapter = Union[structs.StructAdapter, enums.EnumAdapter]
|
|
|
11
11
|
_record_id_to_adapter: dict[str, RecordAdapter] = {}
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
def
|
|
15
|
-
|
|
14
|
+
def init_module_classes(
|
|
15
|
+
records: tuple[spec.Record, ...],
|
|
16
16
|
globals: dict[str, Any],
|
|
17
17
|
# For testing
|
|
18
18
|
record_id_to_adapter: dict[str, RecordAdapter] = _record_id_to_adapter,
|
|
@@ -49,7 +49,7 @@ def init_module(
|
|
|
49
49
|
return record_id_to_adapter[type]
|
|
50
50
|
|
|
51
51
|
module_adapters: list[RecordAdapter] = []
|
|
52
|
-
for record in
|
|
52
|
+
for record in records:
|
|
53
53
|
if record.id in record_id_to_adapter:
|
|
54
54
|
raise AssertionError(record.id)
|
|
55
55
|
adapter: RecordAdapter
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import io
|
|
2
1
|
import json as jsonlib
|
|
3
2
|
from collections.abc import Callable
|
|
4
3
|
from dataclasses import FrozenInstanceError
|
|
5
4
|
from typing import Any, Generic, TypeVar, cast, final
|
|
6
5
|
|
|
7
|
-
from soialib.impl.function_maker import
|
|
6
|
+
from soialib.impl.function_maker import Expr, LineSpan, make_function
|
|
8
7
|
from soialib.impl.type_adapter import TypeAdapter
|
|
9
8
|
from soialib.never import Never
|
|
10
9
|
|
|
@@ -5,258 +5,256 @@ from typing import Any
|
|
|
5
5
|
|
|
6
6
|
from soialib import spec
|
|
7
7
|
from soialib.keyed_items import KeyedItems
|
|
8
|
-
from soialib.module_initializer import
|
|
8
|
+
from soialib.module_initializer import init_module_classes
|
|
9
9
|
from soialib.timestamp import Timestamp
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class ModuleInitializerTestCase(unittest.TestCase):
|
|
13
|
-
def
|
|
13
|
+
def init_test_module_classes(self) -> dict[str, Any]:
|
|
14
14
|
globals: dict[str, Any] = {}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
type=spec.PrimitiveType.FLOAT32,
|
|
25
|
-
),
|
|
26
|
-
spec.Field(
|
|
27
|
-
name="y",
|
|
28
|
-
number=1,
|
|
29
|
-
type=spec.PrimitiveType.FLOAT32,
|
|
30
|
-
),
|
|
15
|
+
init_module_classes(
|
|
16
|
+
(
|
|
17
|
+
spec.Struct(
|
|
18
|
+
id="my/module.soia:Point",
|
|
19
|
+
fields=(
|
|
20
|
+
spec.Field(
|
|
21
|
+
name="x",
|
|
22
|
+
number=0,
|
|
23
|
+
type=spec.PrimitiveType.FLOAT32,
|
|
31
24
|
),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
spec.Field(
|
|
37
|
-
name="a",
|
|
38
|
-
number=0,
|
|
39
|
-
type="my/module.soia:Point",
|
|
40
|
-
has_mutable_getter=True,
|
|
41
|
-
),
|
|
42
|
-
spec.Field(
|
|
43
|
-
name="bb",
|
|
44
|
-
_attribute="b",
|
|
45
|
-
number=1,
|
|
46
|
-
type="my/module.soia:Point",
|
|
47
|
-
has_mutable_getter=True,
|
|
48
|
-
),
|
|
49
|
-
spec.Field(
|
|
50
|
-
name="c",
|
|
51
|
-
number=2,
|
|
52
|
-
type=spec.OptionalType("my/module.soia:Point"),
|
|
53
|
-
has_mutable_getter=True,
|
|
54
|
-
),
|
|
25
|
+
spec.Field(
|
|
26
|
+
name="y",
|
|
27
|
+
number=1,
|
|
28
|
+
type=spec.PrimitiveType.FLOAT32,
|
|
55
29
|
),
|
|
56
30
|
),
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
31
|
+
),
|
|
32
|
+
spec.Struct(
|
|
33
|
+
id="my/module.soia:Segment",
|
|
34
|
+
fields=(
|
|
35
|
+
spec.Field(
|
|
36
|
+
name="a",
|
|
37
|
+
number=0,
|
|
38
|
+
type="my/module.soia:Point",
|
|
39
|
+
has_mutable_getter=True,
|
|
40
|
+
),
|
|
41
|
+
spec.Field(
|
|
42
|
+
name="bb",
|
|
43
|
+
_attribute="b",
|
|
44
|
+
number=1,
|
|
45
|
+
type="my/module.soia:Point",
|
|
46
|
+
has_mutable_getter=True,
|
|
47
|
+
),
|
|
48
|
+
spec.Field(
|
|
49
|
+
name="c",
|
|
50
|
+
number=2,
|
|
51
|
+
type=spec.OptionalType("my/module.soia:Point"),
|
|
52
|
+
has_mutable_getter=True,
|
|
66
53
|
),
|
|
67
54
|
),
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
),
|
|
76
|
-
|
|
77
|
-
name="bytes",
|
|
78
|
-
number=1,
|
|
79
|
-
type=spec.PrimitiveType.BYTES,
|
|
80
|
-
),
|
|
81
|
-
spec.Field(
|
|
82
|
-
name="f32",
|
|
83
|
-
number=2,
|
|
84
|
-
type=spec.PrimitiveType.FLOAT32,
|
|
85
|
-
),
|
|
86
|
-
spec.Field(
|
|
87
|
-
name="f64",
|
|
88
|
-
number=3,
|
|
89
|
-
type=spec.PrimitiveType.FLOAT64,
|
|
90
|
-
),
|
|
91
|
-
spec.Field(
|
|
92
|
-
name="i32",
|
|
93
|
-
number=4,
|
|
94
|
-
type=spec.PrimitiveType.INT32,
|
|
95
|
-
),
|
|
96
|
-
spec.Field(
|
|
97
|
-
name="i64",
|
|
98
|
-
number=5,
|
|
99
|
-
type=spec.PrimitiveType.INT32,
|
|
100
|
-
),
|
|
101
|
-
spec.Field(
|
|
102
|
-
name="u64",
|
|
103
|
-
number=6,
|
|
104
|
-
type=spec.PrimitiveType.INT32,
|
|
105
|
-
),
|
|
106
|
-
spec.Field(
|
|
107
|
-
name="s",
|
|
108
|
-
number=7,
|
|
109
|
-
type=spec.PrimitiveType.STRING,
|
|
110
|
-
),
|
|
111
|
-
spec.Field(
|
|
112
|
-
name="t",
|
|
113
|
-
number=8,
|
|
114
|
-
type=spec.PrimitiveType.TIMESTAMP,
|
|
115
|
-
),
|
|
55
|
+
),
|
|
56
|
+
spec.Struct(
|
|
57
|
+
id="my/module.soia:Shape",
|
|
58
|
+
fields=(
|
|
59
|
+
spec.Field(
|
|
60
|
+
name="points",
|
|
61
|
+
number=0,
|
|
62
|
+
type=spec.ArrayType("my/module.soia:Point"),
|
|
63
|
+
has_mutable_getter=True,
|
|
116
64
|
),
|
|
117
65
|
),
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
spec.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
66
|
+
),
|
|
67
|
+
spec.Struct(
|
|
68
|
+
id="my/module.soia:Primitives",
|
|
69
|
+
fields=(
|
|
70
|
+
spec.Field(
|
|
71
|
+
name="bool",
|
|
72
|
+
number=0,
|
|
73
|
+
type=spec.PrimitiveType.BOOL,
|
|
74
|
+
),
|
|
75
|
+
spec.Field(
|
|
76
|
+
name="bytes",
|
|
77
|
+
number=1,
|
|
78
|
+
type=spec.PrimitiveType.BYTES,
|
|
79
|
+
),
|
|
80
|
+
spec.Field(
|
|
81
|
+
name="f32",
|
|
82
|
+
number=2,
|
|
83
|
+
type=spec.PrimitiveType.FLOAT32,
|
|
84
|
+
),
|
|
85
|
+
spec.Field(
|
|
86
|
+
name="f64",
|
|
87
|
+
number=3,
|
|
88
|
+
type=spec.PrimitiveType.FLOAT64,
|
|
89
|
+
),
|
|
90
|
+
spec.Field(
|
|
91
|
+
name="i32",
|
|
92
|
+
number=4,
|
|
93
|
+
type=spec.PrimitiveType.INT32,
|
|
94
|
+
),
|
|
95
|
+
spec.Field(
|
|
96
|
+
name="i64",
|
|
97
|
+
number=5,
|
|
98
|
+
type=spec.PrimitiveType.INT32,
|
|
99
|
+
),
|
|
100
|
+
spec.Field(
|
|
101
|
+
name="u64",
|
|
102
|
+
number=6,
|
|
103
|
+
type=spec.PrimitiveType.INT32,
|
|
104
|
+
),
|
|
105
|
+
spec.Field(
|
|
106
|
+
name="s",
|
|
107
|
+
number=7,
|
|
108
|
+
type=spec.PrimitiveType.STRING,
|
|
109
|
+
),
|
|
110
|
+
spec.Field(
|
|
111
|
+
name="t",
|
|
112
|
+
number=8,
|
|
113
|
+
type=spec.PrimitiveType.TIMESTAMP,
|
|
133
114
|
),
|
|
134
115
|
),
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
),
|
|
117
|
+
spec.Enum(
|
|
118
|
+
id="my/module.soia:PrimaryColor",
|
|
119
|
+
constant_fields=(
|
|
120
|
+
spec.ConstantField(
|
|
121
|
+
name="RED",
|
|
122
|
+
number=10,
|
|
142
123
|
),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
124
|
+
spec.ConstantField(
|
|
125
|
+
name="GREEN",
|
|
126
|
+
number=20,
|
|
127
|
+
),
|
|
128
|
+
spec.ConstantField(
|
|
129
|
+
name="BLUE",
|
|
130
|
+
number=30,
|
|
149
131
|
),
|
|
150
|
-
removed_numbers=(1, 4),
|
|
151
132
|
),
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
133
|
+
),
|
|
134
|
+
spec.Enum(
|
|
135
|
+
id="my/module.soia:Status",
|
|
136
|
+
constant_fields=(
|
|
137
|
+
spec.ConstantField(
|
|
138
|
+
name="OK",
|
|
139
|
+
number=0,
|
|
159
140
|
),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
spec.ValueField(
|
|
167
|
-
name="number",
|
|
168
|
-
number=2,
|
|
169
|
-
type=spec.PrimitiveType.FLOAT64,
|
|
170
|
-
),
|
|
171
|
-
spec.ValueField(
|
|
172
|
-
name="string",
|
|
173
|
-
number=3,
|
|
174
|
-
type=spec.PrimitiveType.STRING,
|
|
175
|
-
),
|
|
176
|
-
spec.ValueField(
|
|
177
|
-
name="array",
|
|
178
|
-
number=4,
|
|
179
|
-
type=spec.ArrayType("my/module.soia:JsonValue"),
|
|
180
|
-
),
|
|
181
|
-
spec.ValueField(
|
|
182
|
-
name="object",
|
|
183
|
-
number=5,
|
|
184
|
-
type="my/module.soia:JsonValue.Object",
|
|
185
|
-
),
|
|
141
|
+
),
|
|
142
|
+
value_fields=(
|
|
143
|
+
spec.ValueField(
|
|
144
|
+
name="error",
|
|
145
|
+
number=2,
|
|
146
|
+
type=spec.PrimitiveType.STRING,
|
|
186
147
|
),
|
|
187
148
|
),
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
key_attributes=("name",),
|
|
197
|
-
),
|
|
198
|
-
),
|
|
149
|
+
removed_numbers=(1, 4),
|
|
150
|
+
),
|
|
151
|
+
spec.Enum(
|
|
152
|
+
id="my/module.soia:JsonValue",
|
|
153
|
+
constant_fields=(
|
|
154
|
+
spec.ConstantField(
|
|
155
|
+
name="NULL",
|
|
156
|
+
number=0,
|
|
199
157
|
),
|
|
200
158
|
),
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
159
|
+
value_fields=(
|
|
160
|
+
spec.ValueField(
|
|
161
|
+
name="bool",
|
|
162
|
+
number=1,
|
|
163
|
+
type=spec.PrimitiveType.BOOL,
|
|
164
|
+
),
|
|
165
|
+
spec.ValueField(
|
|
166
|
+
name="number",
|
|
167
|
+
number=2,
|
|
168
|
+
type=spec.PrimitiveType.FLOAT64,
|
|
169
|
+
),
|
|
170
|
+
spec.ValueField(
|
|
171
|
+
name="string",
|
|
172
|
+
number=3,
|
|
173
|
+
type=spec.PrimitiveType.STRING,
|
|
174
|
+
),
|
|
175
|
+
spec.ValueField(
|
|
176
|
+
name="array",
|
|
177
|
+
number=4,
|
|
178
|
+
type=spec.ArrayType("my/module.soia:JsonValue"),
|
|
179
|
+
),
|
|
180
|
+
spec.ValueField(
|
|
181
|
+
name="object",
|
|
182
|
+
number=5,
|
|
183
|
+
type="my/module.soia:JsonValue.Object",
|
|
214
184
|
),
|
|
215
185
|
),
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
186
|
+
),
|
|
187
|
+
spec.Struct(
|
|
188
|
+
id="my/module.soia:JsonValue.Object",
|
|
189
|
+
fields=(
|
|
190
|
+
spec.Field(
|
|
191
|
+
name="entries",
|
|
192
|
+
number=0,
|
|
193
|
+
type=spec.ArrayType(
|
|
194
|
+
item="my/module.soia:JsonValue.ObjectEntry",
|
|
195
|
+
key_attributes=("name",),
|
|
196
|
+
),
|
|
197
|
+
),
|
|
219
198
|
),
|
|
220
|
-
|
|
221
|
-
|
|
199
|
+
),
|
|
200
|
+
spec.Struct(
|
|
201
|
+
id="my/module.soia:JsonValue.ObjectEntry",
|
|
202
|
+
fields=(
|
|
203
|
+
spec.Field(
|
|
204
|
+
name="name",
|
|
205
|
+
number=0,
|
|
206
|
+
type=spec.PrimitiveType.STRING,
|
|
207
|
+
),
|
|
208
|
+
spec.Field(
|
|
209
|
+
name="value",
|
|
210
|
+
number=1,
|
|
211
|
+
type="my/module.soia:JsonValue",
|
|
212
|
+
),
|
|
222
213
|
),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
214
|
+
),
|
|
215
|
+
spec.Struct(
|
|
216
|
+
id="my/module.soia:Parent",
|
|
217
|
+
fields=(),
|
|
218
|
+
),
|
|
219
|
+
spec.Enum(
|
|
220
|
+
id="my/module.soia:Parent.NestedEnum",
|
|
221
|
+
),
|
|
222
|
+
spec.Struct(
|
|
223
|
+
id="my/module.soia:Stuff",
|
|
224
|
+
fields=(
|
|
225
|
+
spec.Field(
|
|
226
|
+
name="enum_wrappers",
|
|
227
|
+
number=0,
|
|
228
|
+
type=spec.ArrayType(
|
|
229
|
+
item="my/module.soia:EnumWrapper",
|
|
230
|
+
key_attributes=(
|
|
231
|
+
"status",
|
|
232
|
+
"kind",
|
|
235
233
|
),
|
|
236
234
|
),
|
|
237
235
|
),
|
|
238
236
|
),
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
237
|
+
),
|
|
238
|
+
spec.Struct(
|
|
239
|
+
id="my/module.soia:EnumWrapper",
|
|
240
|
+
fields=(
|
|
241
|
+
spec.Field(
|
|
242
|
+
name="status",
|
|
243
|
+
number=0,
|
|
244
|
+
type="my/module.soia:Status",
|
|
247
245
|
),
|
|
248
246
|
),
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
247
|
+
),
|
|
248
|
+
spec.Struct(
|
|
249
|
+
id="my/module.soia:Stuff.Overrides",
|
|
250
|
+
_class_name="NameOverrides",
|
|
251
|
+
_class_qualname="Stuff.NameOverrides",
|
|
252
|
+
fields=(
|
|
253
|
+
spec.Field(
|
|
254
|
+
name="x",
|
|
255
|
+
_attribute="y",
|
|
256
|
+
number=0,
|
|
257
|
+
type=spec.PrimitiveType.INT32,
|
|
260
258
|
),
|
|
261
259
|
),
|
|
262
260
|
),
|
|
@@ -267,13 +265,13 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
267
265
|
return globals
|
|
268
266
|
|
|
269
267
|
def test_struct_getters(self):
|
|
270
|
-
point_cls = self.
|
|
268
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
271
269
|
point = point_cls(x=1.5, y=2.5)
|
|
272
270
|
self.assertEqual(point.x, 1.5)
|
|
273
271
|
self.assertEqual(point.y, 2.5)
|
|
274
272
|
|
|
275
273
|
def test_to_mutable(self):
|
|
276
|
-
point_cls = self.
|
|
274
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
277
275
|
point = point_cls(x=1.5, y=2.5)
|
|
278
276
|
mutable = point.to_mutable()
|
|
279
277
|
mutable.x = 4.0
|
|
@@ -283,7 +281,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
283
281
|
self.assertIs(point.to_frozen(), point)
|
|
284
282
|
|
|
285
283
|
def test_struct_eq(self):
|
|
286
|
-
point_cls = self.
|
|
284
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
287
285
|
a = point_cls(x=1.5, y=2.5)
|
|
288
286
|
b = point_cls(x=1.5, y=2.5)
|
|
289
287
|
c = point_cls(x=1.5, y=3.0)
|
|
@@ -294,11 +292,11 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
294
292
|
self.assertEqual(point_cls(), point_cls(x=0.0, y=0.0))
|
|
295
293
|
|
|
296
294
|
def test_or_mutable(self):
|
|
297
|
-
point_cls = self.
|
|
295
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
298
296
|
point_cls.OrMutable
|
|
299
297
|
|
|
300
298
|
def test_default_values(self):
|
|
301
|
-
primitives_cls = self.
|
|
299
|
+
primitives_cls = self.init_test_module_classes()["Primitives"]
|
|
302
300
|
a = primitives_cls(
|
|
303
301
|
bool=False,
|
|
304
302
|
bytes=b"",
|
|
@@ -313,29 +311,29 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
313
311
|
self.assertEqual(hash(a), hash(b))
|
|
314
312
|
|
|
315
313
|
def test_to_dense_json(self):
|
|
316
|
-
point_cls = self.
|
|
314
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
317
315
|
point = point_cls(x=1.5, y=2.5)
|
|
318
316
|
json = point_cls.SERIALIZER.to_json(point)
|
|
319
317
|
self.assertEqual(json, [1.5, 2.5])
|
|
320
318
|
|
|
321
319
|
def test_to_readable_json(self):
|
|
322
|
-
point_cls = self.
|
|
320
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
323
321
|
point = point_cls(x=1.5, y=2.5)
|
|
324
322
|
json = point_cls.SERIALIZER.to_json(point, readable_flavor=True)
|
|
325
323
|
self.assertEqual(json, {"x": 1.5, "y": 2.5})
|
|
326
324
|
|
|
327
325
|
def test_from_dense_json(self):
|
|
328
|
-
point_cls = self.
|
|
326
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
329
327
|
point = point_cls.SERIALIZER.from_json([1.5, 2.5])
|
|
330
328
|
self.assertEqual(point, point_cls(x=1.5, y=2.5))
|
|
331
329
|
|
|
332
330
|
def test_from_readable_json(self):
|
|
333
|
-
point_cls = self.
|
|
331
|
+
point_cls = self.init_test_module_classes()["Point"]
|
|
334
332
|
point = point_cls.SERIALIZER.from_json({"x": 1.5, "y": 2.5})
|
|
335
333
|
self.assertEqual(point, point_cls(x=1.5, y=2.5))
|
|
336
334
|
|
|
337
335
|
def test_struct_ctor_accepts_mutable_struct(self):
|
|
338
|
-
module = self.
|
|
336
|
+
module = self.init_test_module_classes()
|
|
339
337
|
segment_cls = module["Segment"]
|
|
340
338
|
point_cls = module["Point"]
|
|
341
339
|
segment = segment_cls(
|
|
@@ -352,7 +350,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
352
350
|
)
|
|
353
351
|
|
|
354
352
|
def test_struct_ctor_checks_type_of_struct_param(self):
|
|
355
|
-
module = self.
|
|
353
|
+
module = self.init_test_module_classes()
|
|
356
354
|
segment_cls = module["Segment"]
|
|
357
355
|
try:
|
|
358
356
|
segment_cls(
|
|
@@ -364,11 +362,11 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
364
362
|
self.assertIn("Point", str(e))
|
|
365
363
|
|
|
366
364
|
def test_struct_ctor_raises_error_if_unknown_arg(self):
|
|
367
|
-
module = self.
|
|
365
|
+
module = self.init_test_module_classes()
|
|
368
366
|
segment_cls = module["Segment"]
|
|
369
367
|
|
|
370
368
|
def test_to_frozen_checks_type_of_struct_field(self):
|
|
371
|
-
module = self.
|
|
369
|
+
module = self.init_test_module_classes()
|
|
372
370
|
segment_cls = module["Segment"]
|
|
373
371
|
mutable = segment_cls.Mutable()
|
|
374
372
|
mutable.a = segment_cls.DEFAULT # Should be a Point
|
|
@@ -379,7 +377,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
379
377
|
self.assertIn("Point", str(e))
|
|
380
378
|
|
|
381
379
|
def test_struct_ctor_accepts_mutable_list(self):
|
|
382
|
-
module = self.
|
|
380
|
+
module = self.init_test_module_classes()
|
|
383
381
|
shape_cls = module["Shape"]
|
|
384
382
|
point_cls = module["Point"]
|
|
385
383
|
shape = shape_cls(
|
|
@@ -399,7 +397,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
399
397
|
)
|
|
400
398
|
|
|
401
399
|
def test_listuple_not_copied(self):
|
|
402
|
-
module = self.
|
|
400
|
+
module = self.init_test_module_classes()
|
|
403
401
|
shape_cls = module["Shape"]
|
|
404
402
|
point_cls = module["Point"]
|
|
405
403
|
shape = shape_cls(
|
|
@@ -414,7 +412,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
414
412
|
self.assertIsNot(other_shape.points.__class__, tuple)
|
|
415
413
|
|
|
416
414
|
def test_single_empty_listuple_instance(self):
|
|
417
|
-
module = self.
|
|
415
|
+
module = self.init_test_module_classes()
|
|
418
416
|
shape_cls = module["Shape"]
|
|
419
417
|
shape = shape_cls(
|
|
420
418
|
points=[],
|
|
@@ -424,7 +422,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
424
422
|
self.assertIsNot(shape.points, ())
|
|
425
423
|
|
|
426
424
|
def test_optional(self):
|
|
427
|
-
module = self.
|
|
425
|
+
module = self.init_test_module_classes()
|
|
428
426
|
segment_cls = module["Segment"]
|
|
429
427
|
point_cls = module["Point"]
|
|
430
428
|
segment = segment_cls(
|
|
@@ -439,7 +437,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
439
437
|
)
|
|
440
438
|
|
|
441
439
|
def test_enum_unknown_constant(self):
|
|
442
|
-
module = self.
|
|
440
|
+
module = self.init_test_module_classes()
|
|
443
441
|
primary_color_cls = module["PrimaryColor"]
|
|
444
442
|
unknown = primary_color_cls.UNKNOWN
|
|
445
443
|
self.assertEqual(unknown.kind, "?")
|
|
@@ -450,7 +448,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
450
448
|
self.assertEqual(serializer.to_json(unknown, readable_flavor=True), "?")
|
|
451
449
|
|
|
452
450
|
def test_enum_user_defined_constant(self):
|
|
453
|
-
module = self.
|
|
451
|
+
module = self.init_test_module_classes()
|
|
454
452
|
primary_color_cls = module["PrimaryColor"]
|
|
455
453
|
red = primary_color_cls.RED
|
|
456
454
|
self.assertEqual(red.kind, "RED")
|
|
@@ -461,7 +459,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
461
459
|
self.assertEqual(serializer.to_json(red, readable_flavor=True), "RED")
|
|
462
460
|
|
|
463
461
|
def test_enum_wrap(self):
|
|
464
|
-
module = self.
|
|
462
|
+
module = self.init_test_module_classes()
|
|
465
463
|
status_cls = module["Status"]
|
|
466
464
|
error = status_cls.wrap_error("An error occurred")
|
|
467
465
|
self.assertEqual(error.kind, "error")
|
|
@@ -475,7 +473,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
475
473
|
)
|
|
476
474
|
|
|
477
475
|
def test_enum_wrap_around_mutable_struct(self):
|
|
478
|
-
module = self.
|
|
476
|
+
module = self.init_test_module_classes()
|
|
479
477
|
json_value_cls = module["JsonValue"]
|
|
480
478
|
json_object_cls = json_value_cls.Object
|
|
481
479
|
json_object = json_value_cls.wrap_object(json_object_cls().to_mutable())
|
|
@@ -486,7 +484,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
486
484
|
)
|
|
487
485
|
|
|
488
486
|
def test_class_name(self):
|
|
489
|
-
module = self.
|
|
487
|
+
module = self.init_test_module_classes()
|
|
490
488
|
shape_cls = module["Shape"]
|
|
491
489
|
json_value_cls = module["JsonValue"]
|
|
492
490
|
json_object_cls = json_value_cls.Object
|
|
@@ -498,7 +496,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
498
496
|
self.assertEqual(json_object_cls.__qualname__, "JsonValue.Object")
|
|
499
497
|
|
|
500
498
|
def test_struct_repr(self):
|
|
501
|
-
module = self.
|
|
499
|
+
module = self.init_test_module_classes()
|
|
502
500
|
point_cls = module["Point"]
|
|
503
501
|
self.assertEqual(
|
|
504
502
|
repr(point_cls(x=1.5)),
|
|
@@ -611,7 +609,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
611
609
|
)
|
|
612
610
|
|
|
613
611
|
def test_enum_constant_repr(self):
|
|
614
|
-
module = self.
|
|
612
|
+
module = self.init_test_module_classes()
|
|
615
613
|
primary_color_cls = module["PrimaryColor"]
|
|
616
614
|
parent_cls = module["Parent"]
|
|
617
615
|
nested_enum_cls = parent_cls.NestedEnum
|
|
@@ -620,7 +618,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
620
618
|
self.assertEqual(repr(nested_enum_cls.UNKNOWN), "Parent.NestedEnum.UNKNOWN")
|
|
621
619
|
|
|
622
620
|
def test_enum_value_repr(self):
|
|
623
|
-
module = self.
|
|
621
|
+
module = self.init_test_module_classes()
|
|
624
622
|
status_cls = module["Status"]
|
|
625
623
|
json_value_cls = module["JsonValue"]
|
|
626
624
|
json_object_cls = json_value_cls.Object
|
|
@@ -658,7 +656,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
658
656
|
)
|
|
659
657
|
|
|
660
658
|
def test_find_in_keyed_items(self):
|
|
661
|
-
json_value_cls = self.
|
|
659
|
+
json_value_cls = self.init_test_module_classes()["JsonValue"]
|
|
662
660
|
object_cls = json_value_cls.Object
|
|
663
661
|
entry_cls = json_value_cls.ObjectEntry
|
|
664
662
|
json_object = object_cls(
|
|
@@ -690,7 +688,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
690
688
|
self.assertIs(entries.find_or_default("zoo"), entry_cls.DEFAULT)
|
|
691
689
|
|
|
692
690
|
def test_find_in_keyed_items_with_complex_path(self):
|
|
693
|
-
module = self.
|
|
691
|
+
module = self.init_test_module_classes()
|
|
694
692
|
stuff_cls = module["Stuff"]
|
|
695
693
|
enum_wrapper_cls = module["EnumWrapper"]
|
|
696
694
|
status_cls = module["Status"]
|
|
@@ -716,14 +714,14 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
716
714
|
self.assertIs(enum_wrappers.find("error"), enum_wrappers[1])
|
|
717
715
|
|
|
718
716
|
def test_name_overrides(self):
|
|
719
|
-
name_overrides_cls = self.
|
|
717
|
+
name_overrides_cls = self.init_test_module_classes()["Stuff"].NameOverrides
|
|
720
718
|
name_overrides = name_overrides_cls(y=3)
|
|
721
719
|
self.assertEqual(name_overrides.y, 3)
|
|
722
720
|
self.assertEqual(name_overrides_cls.__name__, "NameOverrides")
|
|
723
721
|
self.assertEqual(name_overrides_cls.__qualname__, "Stuff.NameOverrides")
|
|
724
722
|
|
|
725
723
|
def test_mutable_getter_of_struct(self):
|
|
726
|
-
module = self.
|
|
724
|
+
module = self.init_test_module_classes()
|
|
727
725
|
segment_cls = module["Segment"]
|
|
728
726
|
point_cls = module["Point"]
|
|
729
727
|
segment = segment_cls(
|
|
@@ -741,7 +739,7 @@ class ModuleInitializerTestCase(unittest.TestCase):
|
|
|
741
739
|
self.assertEqual(str(e), "expected: Point or Point.Mutable; found: str")
|
|
742
740
|
|
|
743
741
|
def test_mutable_getter_of_array(self):
|
|
744
|
-
module = self.
|
|
742
|
+
module = self.init_test_module_classes()
|
|
745
743
|
shape_cls = module["Shape"]
|
|
746
744
|
point_cls = module["Point"]
|
|
747
745
|
shape = shape_cls(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|