jaclang 0.7.16__py3-none-any.whl → 0.7.18__py3-none-any.whl
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 jaclang might be problematic. Click here for more details.
- jaclang/cli/cli.py +140 -77
- jaclang/compiler/absyntree.py +9 -4
- jaclang/compiler/constant.py +8 -8
- jaclang/compiler/parser.py +10 -2
- jaclang/compiler/passes/main/__init__.py +1 -1
- jaclang/compiler/passes/main/access_modifier_pass.py +96 -147
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +152 -50
- jaclang/compiler/passes/main/import_pass.py +88 -59
- jaclang/compiler/passes/main/py_collect_dep_pass.py +70 -0
- jaclang/compiler/passes/main/pyast_gen_pass.py +46 -6
- jaclang/compiler/passes/main/pyast_load_pass.py +1 -0
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +7 -0
- jaclang/compiler/passes/main/schedules.py +9 -2
- jaclang/compiler/passes/main/sym_tab_build_pass.py +9 -5
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.empty.impl.jac +0 -0
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.jac +1 -1
- jaclang/compiler/passes/main/tests/fixtures/py_imp_test.jac +29 -0
- jaclang/compiler/passes/main/tests/fixtures/pygame_mock/__init__.py +3 -0
- jaclang/compiler/passes/main/tests/fixtures/pygame_mock/color.py +3 -0
- jaclang/compiler/passes/main/tests/fixtures/pygame_mock/constants.py +5 -0
- jaclang/compiler/passes/main/tests/fixtures/pygame_mock/display.py +2 -0
- jaclang/compiler/passes/main/tests/test_import_pass.py +72 -13
- jaclang/compiler/passes/main/type_check_pass.py +15 -5
- jaclang/compiler/passes/tool/jac_formatter_pass.py +13 -3
- jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +37 -41
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +37 -41
- jaclang/compiler/passes/tool/tests/fixtures/general_format_checks/access_mod_check.jac +27 -0
- jaclang/compiler/passes/utils/mypy_ast_build.py +45 -0
- jaclang/compiler/symtable.py +16 -11
- jaclang/compiler/tests/test_importer.py +17 -9
- jaclang/langserve/engine.py +64 -16
- jaclang/langserve/server.py +16 -1
- jaclang/langserve/tests/fixtures/import_include_statements.jac +3 -3
- jaclang/langserve/tests/fixtures/rename.jac +30 -0
- jaclang/langserve/tests/test_server.py +224 -6
- jaclang/langserve/utils.py +28 -98
- jaclang/plugin/builtin.py +8 -4
- jaclang/plugin/default.py +86 -64
- jaclang/plugin/feature.py +13 -13
- jaclang/plugin/spec.py +10 -11
- jaclang/plugin/tests/fixtures/other_root_access.jac +82 -0
- jaclang/plugin/tests/test_jaseci.py +414 -42
- jaclang/runtimelib/architype.py +481 -333
- jaclang/runtimelib/constructs.py +5 -8
- jaclang/runtimelib/context.py +89 -69
- jaclang/runtimelib/importer.py +16 -15
- jaclang/runtimelib/machine.py +66 -2
- jaclang/runtimelib/memory.py +134 -75
- jaclang/runtimelib/utils.py +17 -10
- jaclang/settings.py +2 -4
- jaclang/tests/fixtures/access_checker.jac +12 -17
- jaclang/tests/fixtures/access_modifier.jac +88 -33
- jaclang/tests/fixtures/baddy.jac +3 -0
- jaclang/tests/fixtures/bar.jac +34 -0
- jaclang/tests/fixtures/builtin_dotgen.jac +1 -0
- jaclang/tests/fixtures/edge_node_walk.jac +1 -1
- jaclang/tests/fixtures/edge_ops.jac +1 -1
- jaclang/tests/fixtures/edges_walk.jac +1 -1
- jaclang/tests/fixtures/foo.jac +43 -0
- jaclang/tests/fixtures/game1.jac +1 -1
- jaclang/tests/fixtures/gendot_bubble_sort.jac +1 -1
- jaclang/tests/fixtures/import.jac +9 -0
- jaclang/tests/fixtures/index_slice.jac +30 -0
- jaclang/tests/fixtures/objref.jac +12 -0
- jaclang/tests/fixtures/pyfunc_1.py +1 -1
- jaclang/tests/fixtures/pyfunc_2.py +2 -2
- jaclang/tests/fixtures/pygame_mock/__init__.py +3 -0
- jaclang/tests/fixtures/pygame_mock/color.py +3 -0
- jaclang/tests/fixtures/pygame_mock/constants.py +5 -0
- jaclang/tests/fixtures/pygame_mock/display.py +2 -0
- jaclang/tests/fixtures/pygame_mock/inner/__init__.py +0 -0
- jaclang/tests/fixtures/pygame_mock/inner/iner_mod.py +2 -0
- jaclang/tests/test_cli.py +49 -6
- jaclang/tests/test_language.py +126 -80
- jaclang/tests/test_reference.py +2 -9
- jaclang/utils/treeprinter.py +30 -3
- {jaclang-0.7.16.dist-info → jaclang-0.7.18.dist-info}/METADATA +3 -1
- {jaclang-0.7.16.dist-info → jaclang-0.7.18.dist-info}/RECORD +81 -59
- /jaclang/tests/fixtures/{err.test.jac → baddy.test.jac} +0 -0
- {jaclang-0.7.16.dist-info → jaclang-0.7.18.dist-info}/WHEEL +0 -0
- {jaclang-0.7.16.dist-info → jaclang-0.7.18.dist-info}/entry_points.txt +0 -0
|
@@ -7,6 +7,8 @@ import sys
|
|
|
7
7
|
from jaclang.cli import cli
|
|
8
8
|
from jaclang.utils.test import TestCase
|
|
9
9
|
|
|
10
|
+
session = ""
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
class TestJaseciPlugin(TestCase):
|
|
12
14
|
"""Test jaseci plugin."""
|
|
@@ -30,22 +32,27 @@ class TestJaseciPlugin(TestCase):
|
|
|
30
32
|
sys.stdout = sys.__stdout__
|
|
31
33
|
|
|
32
34
|
def _del_session(self, session: str) -> None:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
path = os.path.dirname(session)
|
|
36
|
+
prefix = os.path.basename(session)
|
|
37
|
+
for file in os.listdir(path):
|
|
38
|
+
if file.startswith(prefix):
|
|
39
|
+
os.remove(f"{path}/{file}")
|
|
35
40
|
|
|
36
41
|
def test_walker_simple_persistent(self) -> None:
|
|
37
42
|
"""Test simple persistent object."""
|
|
38
43
|
session = self.fixture_abs_path("test_walker_simple_persistent.session")
|
|
39
44
|
self._output2buffer()
|
|
40
|
-
cli.
|
|
45
|
+
cli.enter(
|
|
41
46
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
42
47
|
session=session,
|
|
43
|
-
|
|
48
|
+
entrypoint="create",
|
|
49
|
+
args=[],
|
|
44
50
|
)
|
|
45
|
-
cli.
|
|
51
|
+
cli.enter(
|
|
46
52
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
47
53
|
session=session,
|
|
48
|
-
|
|
54
|
+
entrypoint="traverse",
|
|
55
|
+
args=[],
|
|
49
56
|
)
|
|
50
57
|
output = self.capturedOutput.getvalue().strip()
|
|
51
58
|
self.assertEqual(output, "node a\nnode b")
|
|
@@ -54,18 +61,24 @@ class TestJaseciPlugin(TestCase):
|
|
|
54
61
|
def test_entrypoint_root(self) -> None:
|
|
55
62
|
"""Test entrypoint being root."""
|
|
56
63
|
session = self.fixture_abs_path("test_entrypoint_root.session")
|
|
57
|
-
cli.
|
|
64
|
+
cli.enter(
|
|
58
65
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
59
66
|
session=session,
|
|
60
|
-
|
|
67
|
+
entrypoint="create",
|
|
68
|
+
args=[],
|
|
69
|
+
)
|
|
70
|
+
obj = cli.get_object(
|
|
71
|
+
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
72
|
+
id="root",
|
|
73
|
+
session=session,
|
|
61
74
|
)
|
|
62
|
-
obj = cli.get_object(session=session, id="root")
|
|
63
75
|
self._output2buffer()
|
|
64
|
-
cli.
|
|
76
|
+
cli.enter(
|
|
65
77
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
66
78
|
session=session,
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
entrypoint="traverse",
|
|
80
|
+
args=[],
|
|
81
|
+
node=str(obj["id"]),
|
|
69
82
|
)
|
|
70
83
|
output = self.capturedOutput.getvalue().strip()
|
|
71
84
|
self.assertEqual(output, "node a\nnode b")
|
|
@@ -74,20 +87,34 @@ class TestJaseciPlugin(TestCase):
|
|
|
74
87
|
def test_entrypoint_non_root(self) -> None:
|
|
75
88
|
"""Test entrypoint being non root node."""
|
|
76
89
|
session = self.fixture_abs_path("test_entrypoint_non_root.session")
|
|
77
|
-
cli.
|
|
90
|
+
cli.enter(
|
|
91
|
+
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
92
|
+
session=session,
|
|
93
|
+
entrypoint="create",
|
|
94
|
+
args=[],
|
|
95
|
+
)
|
|
96
|
+
obj = cli.get_object(
|
|
97
|
+
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
98
|
+
id="root",
|
|
99
|
+
session=session,
|
|
100
|
+
)
|
|
101
|
+
edge_obj = cli.get_object(
|
|
102
|
+
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
103
|
+
id=obj["edges"][0].id.hex,
|
|
104
|
+
session=session,
|
|
105
|
+
)
|
|
106
|
+
a_obj = cli.get_object(
|
|
78
107
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
108
|
+
id=edge_obj["target"].id.hex,
|
|
79
109
|
session=session,
|
|
80
|
-
walker="create",
|
|
81
110
|
)
|
|
82
|
-
obj = cli.get_object(session=session, id="root")
|
|
83
|
-
edge_obj = cli.get_object(session=session, id=str(obj["_jac_"]["edge_ids"][0]))
|
|
84
|
-
a_obj = cli.get_object(session=session, id=str(edge_obj["_jac_"]["target_id"]))
|
|
85
111
|
self._output2buffer()
|
|
86
|
-
cli.
|
|
112
|
+
cli.enter(
|
|
87
113
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
88
114
|
session=session,
|
|
89
|
-
|
|
90
|
-
|
|
115
|
+
entrypoint="traverse",
|
|
116
|
+
node=str(a_obj["id"]),
|
|
117
|
+
args=[],
|
|
91
118
|
)
|
|
92
119
|
output = self.capturedOutput.getvalue().strip()
|
|
93
120
|
self.assertEqual(output, "node a\nnode b")
|
|
@@ -100,16 +127,33 @@ class TestJaseciPlugin(TestCase):
|
|
|
100
127
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
101
128
|
session=session,
|
|
102
129
|
)
|
|
103
|
-
obj = cli.get_object(
|
|
104
|
-
|
|
130
|
+
obj = cli.get_object(
|
|
131
|
+
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
132
|
+
session=session,
|
|
133
|
+
id="root",
|
|
134
|
+
)
|
|
135
|
+
self.assertEqual(len(obj["edges"]), 2)
|
|
105
136
|
edge_objs = [
|
|
106
|
-
cli.get_object(
|
|
107
|
-
|
|
137
|
+
cli.get_object(
|
|
138
|
+
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
139
|
+
session=session,
|
|
140
|
+
id=e.id.hex,
|
|
141
|
+
)
|
|
142
|
+
for e in obj["edges"]
|
|
143
|
+
]
|
|
144
|
+
node_ids = [obj["target"].id.hex for obj in edge_objs]
|
|
145
|
+
node_objs = [
|
|
146
|
+
cli.get_object(
|
|
147
|
+
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
148
|
+
session=session,
|
|
149
|
+
id=str(n_id),
|
|
150
|
+
)
|
|
151
|
+
for n_id in node_ids
|
|
108
152
|
]
|
|
109
|
-
node_ids = [obj["_jac_"]["target_id"] for obj in edge_objs]
|
|
110
|
-
node_objs = [cli.get_object(session=session, id=str(n_id)) for n_id in node_ids]
|
|
111
153
|
self.assertEqual(len(node_objs), 2)
|
|
112
|
-
self.assertEqual(
|
|
154
|
+
self.assertEqual(
|
|
155
|
+
{obj["architype"].tag for obj in node_objs}, {"first", "second"}
|
|
156
|
+
)
|
|
113
157
|
self._del_session(session)
|
|
114
158
|
|
|
115
159
|
def test_filter_on_edge_get_edge(self) -> None:
|
|
@@ -120,10 +164,11 @@ class TestJaseciPlugin(TestCase):
|
|
|
120
164
|
session=session,
|
|
121
165
|
)
|
|
122
166
|
self._output2buffer()
|
|
123
|
-
cli.
|
|
167
|
+
cli.enter(
|
|
124
168
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
125
169
|
session=session,
|
|
126
|
-
|
|
170
|
+
entrypoint="filter_on_edge_get_edge",
|
|
171
|
+
args=[],
|
|
127
172
|
)
|
|
128
173
|
self.assertEqual(
|
|
129
174
|
self.capturedOutput.getvalue().strip(), "[simple_edge(index=1)]"
|
|
@@ -138,10 +183,11 @@ class TestJaseciPlugin(TestCase):
|
|
|
138
183
|
session=session,
|
|
139
184
|
)
|
|
140
185
|
self._output2buffer()
|
|
141
|
-
cli.
|
|
186
|
+
cli.enter(
|
|
142
187
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
143
188
|
session=session,
|
|
144
|
-
|
|
189
|
+
entrypoint="filter_on_edge_get_node",
|
|
190
|
+
args=[],
|
|
145
191
|
)
|
|
146
192
|
self.assertEqual(
|
|
147
193
|
self.capturedOutput.getvalue().strip(), "[simple(tag='second')]"
|
|
@@ -156,10 +202,11 @@ class TestJaseciPlugin(TestCase):
|
|
|
156
202
|
session=session,
|
|
157
203
|
)
|
|
158
204
|
self._output2buffer()
|
|
159
|
-
cli.
|
|
205
|
+
cli.enter(
|
|
160
206
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
161
207
|
session=session,
|
|
162
|
-
|
|
208
|
+
entrypoint="filter_on_node_get_node",
|
|
209
|
+
args=[],
|
|
163
210
|
)
|
|
164
211
|
self.assertEqual(
|
|
165
212
|
self.capturedOutput.getvalue().strip(), "[simple(tag='second')]"
|
|
@@ -174,10 +221,11 @@ class TestJaseciPlugin(TestCase):
|
|
|
174
221
|
session=session,
|
|
175
222
|
)
|
|
176
223
|
self._output2buffer()
|
|
177
|
-
cli.
|
|
224
|
+
cli.enter(
|
|
178
225
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
179
226
|
session=session,
|
|
180
|
-
|
|
227
|
+
entrypoint="filter_on_edge_visit",
|
|
228
|
+
args=[],
|
|
181
229
|
)
|
|
182
230
|
self.assertEqual(self.capturedOutput.getvalue().strip(), "simple(tag='first')")
|
|
183
231
|
self._del_session(session)
|
|
@@ -190,10 +238,11 @@ class TestJaseciPlugin(TestCase):
|
|
|
190
238
|
session=session,
|
|
191
239
|
)
|
|
192
240
|
self._output2buffer()
|
|
193
|
-
cli.
|
|
241
|
+
cli.enter(
|
|
194
242
|
filename=self.fixture_abs_path("simple_node_connection.jac"),
|
|
195
243
|
session=session,
|
|
196
|
-
|
|
244
|
+
entrypoint="filter_on_node_visit",
|
|
245
|
+
args=[],
|
|
197
246
|
)
|
|
198
247
|
self.assertEqual(self.capturedOutput.getvalue().strip(), "simple(tag='first')")
|
|
199
248
|
self._del_session(session)
|
|
@@ -201,19 +250,342 @@ class TestJaseciPlugin(TestCase):
|
|
|
201
250
|
def test_indirect_reference_node(self) -> None:
|
|
202
251
|
"""Test reference node indirectly without visiting."""
|
|
203
252
|
session = self.fixture_abs_path("test_indirect_reference_node.session")
|
|
204
|
-
cli.
|
|
253
|
+
cli.enter(
|
|
205
254
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
206
255
|
session=session,
|
|
207
|
-
|
|
256
|
+
entrypoint="create",
|
|
257
|
+
args=[],
|
|
208
258
|
)
|
|
209
259
|
self._output2buffer()
|
|
210
|
-
cli.
|
|
260
|
+
cli.enter(
|
|
211
261
|
filename=self.fixture_abs_path("simple_persistent.jac"),
|
|
212
262
|
session=session,
|
|
213
|
-
|
|
263
|
+
entrypoint="indirect_ref",
|
|
264
|
+
args=[],
|
|
214
265
|
)
|
|
215
266
|
self.assertEqual(
|
|
216
267
|
self.capturedOutput.getvalue().strip(),
|
|
217
|
-
"[b(name='node b')]\n[GenericEdge]",
|
|
268
|
+
"[b(name='node b')]\n[GenericEdge()]",
|
|
218
269
|
)
|
|
219
270
|
self._del_session(session)
|
|
271
|
+
|
|
272
|
+
def trigger_access_validation_test(
|
|
273
|
+
self, give_access_to_full_graph: bool, via_all: bool = False
|
|
274
|
+
) -> None:
|
|
275
|
+
"""Test different access validation."""
|
|
276
|
+
self._output2buffer()
|
|
277
|
+
|
|
278
|
+
##############################################
|
|
279
|
+
# ALLOW READ ACCESS #
|
|
280
|
+
##############################################
|
|
281
|
+
|
|
282
|
+
node_1 = "" if give_access_to_full_graph else self.nodes[0]
|
|
283
|
+
node_2 = "" if give_access_to_full_graph else self.nodes[1]
|
|
284
|
+
|
|
285
|
+
cli.enter(
|
|
286
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
287
|
+
entrypoint="allow_other_root_access",
|
|
288
|
+
args=[self.roots[1], 0, via_all],
|
|
289
|
+
session=session,
|
|
290
|
+
root=self.roots[0],
|
|
291
|
+
node=node_1,
|
|
292
|
+
)
|
|
293
|
+
cli.enter(
|
|
294
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
295
|
+
entrypoint="allow_other_root_access",
|
|
296
|
+
args=[self.roots[0], 0, via_all],
|
|
297
|
+
session=session,
|
|
298
|
+
root=self.roots[1],
|
|
299
|
+
node=node_2,
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
cli.enter(
|
|
303
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
304
|
+
entrypoint="update_node",
|
|
305
|
+
args=[20],
|
|
306
|
+
session=session,
|
|
307
|
+
root=self.roots[0],
|
|
308
|
+
node=self.nodes[1],
|
|
309
|
+
)
|
|
310
|
+
cli.enter(
|
|
311
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
312
|
+
entrypoint="update_node",
|
|
313
|
+
args=[10],
|
|
314
|
+
session=session,
|
|
315
|
+
root=self.roots[1],
|
|
316
|
+
node=self.nodes[0],
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
cli.enter(
|
|
320
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
321
|
+
entrypoint="check_node",
|
|
322
|
+
args=[],
|
|
323
|
+
session=session,
|
|
324
|
+
root=self.roots[0],
|
|
325
|
+
node=self.nodes[1],
|
|
326
|
+
)
|
|
327
|
+
cli.enter(
|
|
328
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
329
|
+
entrypoint="check_node",
|
|
330
|
+
args=[],
|
|
331
|
+
session=session,
|
|
332
|
+
root=self.roots[1],
|
|
333
|
+
node=self.nodes[0],
|
|
334
|
+
)
|
|
335
|
+
archs = self.capturedOutput.getvalue().strip().split("\n")
|
|
336
|
+
self.assertTrue(len(archs) == 2)
|
|
337
|
+
|
|
338
|
+
# --------- NO UPDATE SHOULD HAPPEN -------- #
|
|
339
|
+
|
|
340
|
+
self.assertTrue(archs[0], "A(val=2)")
|
|
341
|
+
self.assertTrue(archs[1], "A(val=1)")
|
|
342
|
+
|
|
343
|
+
self._output2buffer()
|
|
344
|
+
cli.enter(
|
|
345
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
346
|
+
entrypoint="disallow_other_root_access",
|
|
347
|
+
args=[self.roots[1], via_all],
|
|
348
|
+
session=session,
|
|
349
|
+
root=self.roots[0],
|
|
350
|
+
node=node_1,
|
|
351
|
+
)
|
|
352
|
+
cli.enter(
|
|
353
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
354
|
+
entrypoint="disallow_other_root_access",
|
|
355
|
+
args=[self.roots[0], via_all],
|
|
356
|
+
session=session,
|
|
357
|
+
root=self.roots[1],
|
|
358
|
+
node=node_2,
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
cli.enter(
|
|
362
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
363
|
+
entrypoint="check_node",
|
|
364
|
+
args=[],
|
|
365
|
+
session=session,
|
|
366
|
+
root=self.roots[0],
|
|
367
|
+
node=self.nodes[1],
|
|
368
|
+
)
|
|
369
|
+
cli.enter(
|
|
370
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
371
|
+
entrypoint="check_node",
|
|
372
|
+
args=[],
|
|
373
|
+
session=session,
|
|
374
|
+
root=self.roots[1],
|
|
375
|
+
node=self.nodes[0],
|
|
376
|
+
)
|
|
377
|
+
self.assertFalse(self.capturedOutput.getvalue().strip())
|
|
378
|
+
|
|
379
|
+
##############################################
|
|
380
|
+
# ALLOW WRITE ACCESS #
|
|
381
|
+
##############################################
|
|
382
|
+
|
|
383
|
+
cli.enter(
|
|
384
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
385
|
+
entrypoint="allow_other_root_access",
|
|
386
|
+
args=[self.roots[1], "WRITE", via_all],
|
|
387
|
+
session=session,
|
|
388
|
+
root=self.roots[0],
|
|
389
|
+
node=node_1,
|
|
390
|
+
)
|
|
391
|
+
cli.enter(
|
|
392
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
393
|
+
entrypoint="allow_other_root_access",
|
|
394
|
+
args=[self.roots[0], "WRITE", via_all],
|
|
395
|
+
session=session,
|
|
396
|
+
root=self.roots[1],
|
|
397
|
+
node=node_2,
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
cli.enter(
|
|
401
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
402
|
+
entrypoint="update_node",
|
|
403
|
+
args=[20],
|
|
404
|
+
root=self.roots[0],
|
|
405
|
+
node=self.nodes[1],
|
|
406
|
+
session=session,
|
|
407
|
+
)
|
|
408
|
+
cli.enter(
|
|
409
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
410
|
+
entrypoint="update_node",
|
|
411
|
+
args=[10],
|
|
412
|
+
session=session,
|
|
413
|
+
root=self.roots[1],
|
|
414
|
+
node=self.nodes[0],
|
|
415
|
+
)
|
|
416
|
+
|
|
417
|
+
cli.enter(
|
|
418
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
419
|
+
entrypoint="check_node",
|
|
420
|
+
args=[],
|
|
421
|
+
session=session,
|
|
422
|
+
root=self.roots[0],
|
|
423
|
+
node=self.nodes[1],
|
|
424
|
+
)
|
|
425
|
+
cli.enter(
|
|
426
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
427
|
+
entrypoint="check_node",
|
|
428
|
+
args=[],
|
|
429
|
+
session=session,
|
|
430
|
+
root=self.roots[1],
|
|
431
|
+
node=self.nodes[0],
|
|
432
|
+
)
|
|
433
|
+
archs = self.capturedOutput.getvalue().strip().split("\n")
|
|
434
|
+
self.assertTrue(len(archs) == 2)
|
|
435
|
+
|
|
436
|
+
# --------- UPDATE SHOULD HAPPEN -------- #
|
|
437
|
+
|
|
438
|
+
self.assertTrue(archs[0], "A(val=20)")
|
|
439
|
+
self.assertTrue(archs[1], "A(val=10)")
|
|
440
|
+
|
|
441
|
+
self._output2buffer()
|
|
442
|
+
cli.enter(
|
|
443
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
444
|
+
entrypoint="disallow_other_root_access",
|
|
445
|
+
args=[self.roots[1], via_all],
|
|
446
|
+
session=session,
|
|
447
|
+
root=self.roots[0],
|
|
448
|
+
node=node_1,
|
|
449
|
+
)
|
|
450
|
+
cli.enter(
|
|
451
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
452
|
+
entrypoint="disallow_other_root_access",
|
|
453
|
+
args=[self.roots[0], via_all],
|
|
454
|
+
session=session,
|
|
455
|
+
root=self.roots[1],
|
|
456
|
+
node=node_2,
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
cli.enter(
|
|
460
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
461
|
+
entrypoint="check_node",
|
|
462
|
+
args=[],
|
|
463
|
+
session=session,
|
|
464
|
+
root=self.roots[0],
|
|
465
|
+
node=self.nodes[1],
|
|
466
|
+
)
|
|
467
|
+
cli.enter(
|
|
468
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
469
|
+
entrypoint="check_node",
|
|
470
|
+
args=[],
|
|
471
|
+
session=session,
|
|
472
|
+
root=self.roots[1],
|
|
473
|
+
node=self.nodes[0],
|
|
474
|
+
)
|
|
475
|
+
self.assertFalse(self.capturedOutput.getvalue().strip())
|
|
476
|
+
|
|
477
|
+
def test_other_root_access(self) -> None:
|
|
478
|
+
"""Test filtering on node, then visit."""
|
|
479
|
+
global session
|
|
480
|
+
session = self.fixture_abs_path("other_root_access.session")
|
|
481
|
+
|
|
482
|
+
##############################################
|
|
483
|
+
# CREATE ROOTS #
|
|
484
|
+
##############################################
|
|
485
|
+
|
|
486
|
+
self._output2buffer()
|
|
487
|
+
cli.enter(
|
|
488
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
489
|
+
entrypoint="create_other_root",
|
|
490
|
+
args=[],
|
|
491
|
+
session=session,
|
|
492
|
+
)
|
|
493
|
+
root1 = self.capturedOutput.getvalue().strip()
|
|
494
|
+
|
|
495
|
+
self._output2buffer()
|
|
496
|
+
cli.enter(
|
|
497
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
498
|
+
entrypoint="create_other_root",
|
|
499
|
+
args=[],
|
|
500
|
+
session=session,
|
|
501
|
+
)
|
|
502
|
+
root2 = self.capturedOutput.getvalue().strip()
|
|
503
|
+
|
|
504
|
+
##############################################
|
|
505
|
+
# CREATE RESPECTIVE NODES #
|
|
506
|
+
##############################################
|
|
507
|
+
|
|
508
|
+
self._output2buffer()
|
|
509
|
+
cli.enter(
|
|
510
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
511
|
+
entrypoint="create_node",
|
|
512
|
+
args=[1],
|
|
513
|
+
session=session,
|
|
514
|
+
root=root1,
|
|
515
|
+
)
|
|
516
|
+
cli.enter(
|
|
517
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
518
|
+
entrypoint="create_node",
|
|
519
|
+
args=[2],
|
|
520
|
+
session=session,
|
|
521
|
+
root=root2,
|
|
522
|
+
)
|
|
523
|
+
nodes = self.capturedOutput.getvalue().strip().split("\n")
|
|
524
|
+
self.assertTrue(len(nodes) == 2)
|
|
525
|
+
|
|
526
|
+
##############################################
|
|
527
|
+
# VISIT RESPECTIVE NODES #
|
|
528
|
+
##############################################
|
|
529
|
+
|
|
530
|
+
self._output2buffer()
|
|
531
|
+
cli.enter(
|
|
532
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
533
|
+
entrypoint="check_node",
|
|
534
|
+
args=[],
|
|
535
|
+
session=session,
|
|
536
|
+
root=root1,
|
|
537
|
+
)
|
|
538
|
+
cli.enter(
|
|
539
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
540
|
+
entrypoint="check_node",
|
|
541
|
+
args=[],
|
|
542
|
+
session=session,
|
|
543
|
+
root=root2,
|
|
544
|
+
)
|
|
545
|
+
archs = self.capturedOutput.getvalue().strip().split("\n")
|
|
546
|
+
self.assertEqual(2, len(archs))
|
|
547
|
+
self.assertTrue(archs[0], "A(val=1)")
|
|
548
|
+
self.assertTrue(archs[1], "A(val=2)")
|
|
549
|
+
|
|
550
|
+
##############################################
|
|
551
|
+
# SWAP TARGET NODE #
|
|
552
|
+
# NO ACCESS #
|
|
553
|
+
##############################################
|
|
554
|
+
|
|
555
|
+
self._output2buffer()
|
|
556
|
+
cli.enter(
|
|
557
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
558
|
+
entrypoint="check_node",
|
|
559
|
+
args=[],
|
|
560
|
+
session=session,
|
|
561
|
+
root=root1,
|
|
562
|
+
node=nodes[1],
|
|
563
|
+
)
|
|
564
|
+
cli.enter(
|
|
565
|
+
filename=self.fixture_abs_path("other_root_access.jac"),
|
|
566
|
+
entrypoint="check_node",
|
|
567
|
+
args=[],
|
|
568
|
+
session=session,
|
|
569
|
+
root=root2,
|
|
570
|
+
node=nodes[0],
|
|
571
|
+
)
|
|
572
|
+
self.assertFalse(self.capturedOutput.getvalue().strip())
|
|
573
|
+
|
|
574
|
+
##############################################
|
|
575
|
+
# TEST DIFFERENT ACCESS OPTIONS #
|
|
576
|
+
##############################################
|
|
577
|
+
|
|
578
|
+
self.roots = [root1, root2]
|
|
579
|
+
self.nodes = nodes
|
|
580
|
+
|
|
581
|
+
self.trigger_access_validation_test(give_access_to_full_graph=False)
|
|
582
|
+
self.trigger_access_validation_test(give_access_to_full_graph=True)
|
|
583
|
+
|
|
584
|
+
self.trigger_access_validation_test(
|
|
585
|
+
give_access_to_full_graph=False, via_all=True
|
|
586
|
+
)
|
|
587
|
+
self.trigger_access_validation_test(
|
|
588
|
+
give_access_to_full_graph=True, via_all=True
|
|
589
|
+
)
|
|
590
|
+
|
|
591
|
+
self._del_session(session)
|