jaseci 1.4.2.5__py3-none-any.whl → 2.0.0__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 jaseci might be problematic. Click here for more details.
- jaseci/__init__.py +3 -37
- jaseci-2.0.0.dist-info/METADATA +65 -0
- jaseci-2.0.0.dist-info/RECORD +4 -0
- {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
- jaseci/VERSION +0 -1
- jaseci/cli_tools/__init__.py +0 -0
- jaseci/cli_tools/book_tools.py +0 -457
- jaseci/cli_tools/jsctl.py +0 -500
- jaseci/cli_tools/tests/__init__.py +0 -0
- jaseci/cli_tools/tests/test_jsctl.py +0 -556
- jaseci/extens/__init__.py +0 -0
- jaseci/extens/act_lib/__init__.py +0 -0
- jaseci/extens/act_lib/date.py +0 -117
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -76
- jaseci/extens/act_lib/file_handler.py +0 -189
- jaseci/extens/act_lib/internal.py +0 -18
- jaseci/extens/act_lib/jaseci.py +0 -61
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -191
- jaseci/extens/act_lib/rand.py +0 -82
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -169
- jaseci/extens/act_lib/std.py +0 -235
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -337
- jaseci/extens/act_lib/task.py +0 -13
- jaseci/extens/act_lib/tests/__init__.py +0 -0
- jaseci/extens/act_lib/tests/std_test_code.py +0 -37
- jaseci/extens/act_lib/tests/test_date.py +0 -26
- jaseci/extens/act_lib/tests/test_elastic.py +0 -159
- jaseci/extens/act_lib/tests/test_file.py +0 -116
- jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
- jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
- jaseci/extens/act_lib/tests/test_maths.py +0 -147
- jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
- jaseci/extens/act_lib/tests/test_regex.py +0 -61
- jaseci/extens/act_lib/tests/test_std.py +0 -51
- jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
- jaseci/extens/act_lib/tests/test_url.py +0 -32
- jaseci/extens/act_lib/tests/test_vector.py +0 -36
- jaseci/extens/act_lib/tests/test_webtool.py +0 -44
- jaseci/extens/act_lib/tests/test_zlib.py +0 -24
- jaseci/extens/act_lib/url.py +0 -79
- jaseci/extens/act_lib/vector.py +0 -157
- jaseci/extens/act_lib/webtool.py +0 -28
- jaseci/extens/act_lib/zip.py +0 -33
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -170
- jaseci/extens/api/alias_api.py +0 -139
- jaseci/extens/api/architype_api.py +0 -196
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -84
- jaseci/extens/api/graph_api.py +0 -167
- jaseci/extens/api/health_api.py +0 -20
- jaseci/extens/api/interface.py +0 -268
- jaseci/extens/api/jac_api.py +0 -171
- jaseci/extens/api/jsorc_api.py +0 -316
- jaseci/extens/api/logger_api.py +0 -89
- jaseci/extens/api/master_api.py +0 -133
- jaseci/extens/api/object_api.py +0 -101
- jaseci/extens/api/prometheus_api.py +0 -74
- jaseci/extens/api/queue_api.py +0 -140
- jaseci/extens/api/sentinel_api.py +0 -270
- jaseci/extens/api/super_api.py +0 -64
- jaseci/extens/api/tests/__init__.py +0 -0
- jaseci/extens/api/tests/test_architype_api.py +0 -66
- jaseci/extens/api/tests/test_global_api.py +0 -179
- jaseci/extens/api/tests/test_graph_api.py +0 -64
- jaseci/extens/api/tests/test_logger_api.py +0 -43
- jaseci/extens/api/tests/test_object_api.py +0 -20
- jaseci/extens/api/tests/test_sentinel_api.py +0 -66
- jaseci/extens/api/tests/test_uncommon.py +0 -107
- jaseci/extens/api/tests/test_user_api.py +0 -32
- jaseci/extens/api/tests/test_walker_api.py +0 -316
- jaseci/extens/api/user_api.py +0 -144
- jaseci/extens/api/walker_api.py +0 -298
- jaseci/extens/api/webhook_api.py +0 -74
- jaseci/extens/svc/__init__.py +0 -0
- jaseci/extens/svc/elastic_svc.py +0 -366
- jaseci/extens/svc/kube_svc.py +0 -432
- jaseci/extens/svc/mail_svc.py +0 -156
- jaseci/extens/svc/prome_svc.py +0 -378
- jaseci/extens/svc/redis_svc.py +0 -63
- jaseci/extens/svc/storage_svc.py +0 -193
- jaseci/extens/svc/stripe_svc.py +0 -51
- jaseci/extens/svc/task_svc.py +0 -155
- jaseci/extens/svc/tasks.py +0 -302
- jaseci/jac/__init__.py +0 -0
- jaseci/jac/interpreter/__init__.py +0 -0
- jaseci/jac/interpreter/architype_interp.py +0 -214
- jaseci/jac/interpreter/interp.py +0 -1783
- jaseci/jac/interpreter/sentinel_interp.py +0 -257
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -248
- jaseci/jac/ir/__init__.py +0 -0
- jaseci/jac/ir/ast.py +0 -73
- jaseci/jac/ir/ast_builder.py +0 -249
- jaseci/jac/ir/jac_code.py +0 -152
- jaseci/jac/ir/passes/__init__.py +0 -6
- jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
- jaseci/jac/ir/passes/codegen_pass.py +0 -244
- jaseci/jac/ir/passes/ir_pass.py +0 -29
- jaseci/jac/ir/passes/printer_pass.py +0 -23
- jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
- jaseci/jac/ir/passes/schedule.py +0 -23
- jaseci/jac/ir/passes/stats_pass.py +0 -16
- jaseci/jac/jac.g4 +0 -450
- jaseci/jac/jac_parse/__init__.py +0 -0
- jaseci/jac/jac_parse/jacLexer.py +0 -809
- jaseci/jac/jac_parse/jacListener.py +0 -853
- jaseci/jac/jac_parse/jacParser.py +0 -9192
- jaseci/jac/jac_set.py +0 -119
- jaseci/jac/jsci_vm/__init__.py +0 -0
- jaseci/jac/jsci_vm/disasm.py +0 -94
- jaseci/jac/jsci_vm/inst_ptr.py +0 -31
- jaseci/jac/jsci_vm/machine.py +0 -188
- jaseci/jac/jsci_vm/op_codes.py +0 -82
- jaseci/jac/jsci_vm/tests/__init__.py +0 -0
- jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
- jaseci/jac/machine/__init__.py +0 -0
- jaseci/jac/machine/jac_scope.py +0 -85
- jaseci/jac/machine/jac_value.py +0 -226
- jaseci/jac/machine/machine_state.py +0 -383
- jaseci/jac/tests/__init__.py +0 -0
- jaseci/jac/tests/book_code.py +0 -624
- jaseci/jac/tests/test_book.py +0 -380
- jaseci/jac/tests/test_lang_14.py +0 -49
- jaseci/jsorc/__init__.py +0 -7
- jaseci/jsorc/jsorc.py +0 -642
- jaseci/jsorc/jsorc_settings.py +0 -211
- jaseci/jsorc/jsorc_utils.py +0 -298
- jaseci/jsorc/live_actions.py +0 -364
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6024
- jaseci/jsorc/manifests/prometheus.yaml +0 -1383
- jaseci/jsorc/manifests/redis.yaml +0 -64
- jaseci/jsorc/memory.py +0 -258
- jaseci/jsorc/redis.py +0 -139
- jaseci/jsorc/remote_actions.py +0 -157
- jaseci/jsorc/tests/__init__.py +0 -0
- jaseci/jsorc/tests/test_actions.py +0 -542
- jaseci/jsorc/tests/test_jsorc.py +0 -112
- jaseci/prim/__init__.py +0 -0
- jaseci/prim/ability.py +0 -93
- jaseci/prim/architype.py +0 -89
- jaseci/prim/edge.py +0 -172
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -26
- jaseci/prim/master.py +0 -64
- jaseci/prim/node.py +0 -532
- jaseci/prim/obj_mixins.py +0 -235
- jaseci/prim/sentinel.py +0 -281
- jaseci/prim/super_master.py +0 -31
- jaseci/prim/walker.py +0 -261
- jaseci/svc/__init__.py +0 -0
- jaseci/tests/__init__.py +0 -0
- jaseci/tests/infer.py +0 -39
- jaseci/tests/jac_test_code.py +0 -1293
- jaseci/tests/jac_test_progs.py +0 -774
- jaseci/tests/test_core.py +0 -153
- jaseci/tests/test_jac.py +0 -824
- jaseci/tests/test_node.py +0 -89
- jaseci/tests/test_progs.py +0 -702
- jaseci/tests/test_stack.py +0 -220
- jaseci/tests/test_stripe.py +0 -225
- jaseci/utils/__init__.py +0 -0
- jaseci/utils/actions/__init__.py +0 -0
- jaseci/utils/actions/actions_manager.py +0 -254
- jaseci/utils/actions/actions_optimizer.py +0 -516
- jaseci/utils/actions/actions_state.py +0 -95
- jaseci/utils/file_handler.py +0 -171
- jaseci/utils/gprof2dot.py +0 -3786
- jaseci/utils/id_list.py +0 -168
- jaseci/utils/json_handler.py +0 -70
- jaseci/utils/log_utils.py +0 -57
- jaseci/utils/test_core.py +0 -62
- jaseci/utils/utils.py +0 -387
- jaseci-1.4.2.5.dist-info/LICENSE +0 -21
- jaseci-1.4.2.5.dist-info/METADATA +0 -39
- jaseci-1.4.2.5.dist-info/RECORD +0 -184
- jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
- jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
|
@@ -1,316 +0,0 @@
|
|
|
1
|
-
from jaseci.prim.edge import Edge
|
|
2
|
-
from jaseci.prim.node import Node
|
|
3
|
-
from jaseci.utils.test_core import CoreTest
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class WalkerApiTest(CoreTest):
|
|
7
|
-
"""Unit tests for Jac Walker APIs"""
|
|
8
|
-
|
|
9
|
-
fixture_src = __file__
|
|
10
|
-
|
|
11
|
-
def test_walker_yield(self):
|
|
12
|
-
self.call(
|
|
13
|
-
self.mast,
|
|
14
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
15
|
-
)
|
|
16
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
17
|
-
self.assertEqual(ret["report"], ["entering", 7])
|
|
18
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
19
|
-
self.assertEqual(ret["report"], [8])
|
|
20
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
21
|
-
self.assertEqual(ret["report"], [9])
|
|
22
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
23
|
-
self.assertEqual(ret["report"], [10])
|
|
24
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
25
|
-
self.assertEqual(ret["report"], ["should start over now", "exiting"])
|
|
26
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
27
|
-
self.assertEqual(ret["report"], ["entering", 7])
|
|
28
|
-
|
|
29
|
-
def test_walker_yield_update(self):
|
|
30
|
-
self.call(
|
|
31
|
-
self.mast,
|
|
32
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
33
|
-
)
|
|
34
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
35
|
-
self.assertEqual(ret["report"], ["entering", 7])
|
|
36
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
37
|
-
self.assertEqual(ret["report"], [8])
|
|
38
|
-
ret = self.call(
|
|
39
|
-
self.mast, ["walker_run", {"name": "test_yield", "ctx": {"a": 2}}]
|
|
40
|
-
)
|
|
41
|
-
self.assertEqual(ret["report"], [3])
|
|
42
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
43
|
-
self.assertEqual(ret["report"], [4])
|
|
44
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
45
|
-
self.assertEqual(ret["report"], [5])
|
|
46
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
47
|
-
self.assertEqual(ret["report"], [6])
|
|
48
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
49
|
-
self.assertEqual(ret["report"], [7])
|
|
50
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
51
|
-
self.assertEqual(ret["report"], [8])
|
|
52
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
53
|
-
self.assertEqual(ret["report"], [9])
|
|
54
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
55
|
-
self.assertEqual(ret["report"], [10])
|
|
56
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
57
|
-
self.assertEqual(ret["report"], ["should start over now", "exiting"])
|
|
58
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield"}])
|
|
59
|
-
self.assertEqual(ret["report"], ["entering", 7])
|
|
60
|
-
|
|
61
|
-
def test_walker_yield_report(self):
|
|
62
|
-
self.call(
|
|
63
|
-
self.mast,
|
|
64
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
65
|
-
)
|
|
66
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
67
|
-
self.assertEqual(ret["report"], [7])
|
|
68
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
69
|
-
self.assertEqual(ret["report"], [8])
|
|
70
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
71
|
-
self.assertEqual(ret["report"], [9])
|
|
72
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
73
|
-
self.assertEqual(ret["report"], [10])
|
|
74
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
75
|
-
self.assertEqual(ret["report"], ["should start over now"])
|
|
76
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_report"}])
|
|
77
|
-
self.assertEqual(ret["report"], [7])
|
|
78
|
-
|
|
79
|
-
def test_walker_yield_disengage(self):
|
|
80
|
-
self.call(
|
|
81
|
-
self.mast,
|
|
82
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
83
|
-
)
|
|
84
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
85
|
-
self.assertEqual(ret["report"], [7])
|
|
86
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
87
|
-
self.assertEqual(ret["report"], [8])
|
|
88
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
89
|
-
self.assertEqual(ret["report"], [9])
|
|
90
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
91
|
-
self.assertEqual(ret["report"], [10])
|
|
92
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
93
|
-
self.assertEqual(ret["report"], ["should start over now"])
|
|
94
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_disengage"}])
|
|
95
|
-
self.assertEqual(ret["report"], [7])
|
|
96
|
-
|
|
97
|
-
def test_walker_yield_take(self):
|
|
98
|
-
self.call(
|
|
99
|
-
self.mast,
|
|
100
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
101
|
-
)
|
|
102
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
103
|
-
self.assertEqual(ret["report"], [7, "test"])
|
|
104
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
105
|
-
self.assertEqual(ret["report"], [8, "test"])
|
|
106
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
107
|
-
self.assertEqual(ret["report"], [9, "test"])
|
|
108
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
109
|
-
self.assertEqual(ret["report"], [10, "test"])
|
|
110
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
111
|
-
self.assertEqual(ret["report"], ["should start over now"])
|
|
112
|
-
ret = self.call(self.mast, ["walker_run", {"name": "test_yield_take"}])
|
|
113
|
-
self.assertEqual(ret["report"], [7, "test"])
|
|
114
|
-
|
|
115
|
-
def test_walker_smart_yield(self):
|
|
116
|
-
self.call(
|
|
117
|
-
self.mast,
|
|
118
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
119
|
-
)
|
|
120
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield"}])
|
|
121
|
-
before = self.mast._h.get_object_distribution()
|
|
122
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield"}])
|
|
123
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield"}])
|
|
124
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield"}])
|
|
125
|
-
after = self.mast._h.get_object_distribution()
|
|
126
|
-
self.assertEqual(before, after)
|
|
127
|
-
self.assertEqual(ret["report"], [{"id": 2}])
|
|
128
|
-
|
|
129
|
-
def test_walker_smart_yield_no_future(self):
|
|
130
|
-
self.call(
|
|
131
|
-
self.mast,
|
|
132
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
133
|
-
)
|
|
134
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield_no_future"}])
|
|
135
|
-
before = self.mast._h.get_object_distribution()
|
|
136
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield_no_future"}])
|
|
137
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield_no_future"}])
|
|
138
|
-
ret = self.call(self.mast, ["walker_run", {"name": "smart_yield_no_future"}])
|
|
139
|
-
after = self.mast._h.get_object_distribution()
|
|
140
|
-
self.assertEqual(before, after)
|
|
141
|
-
self.assertEqual(ret["report"], [{}])
|
|
142
|
-
|
|
143
|
-
def test_walker_deep_yield(self):
|
|
144
|
-
self.call(
|
|
145
|
-
self.mast,
|
|
146
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
147
|
-
)
|
|
148
|
-
ret = self.call(self.mast, ["walker_run", {"name": "deep_yield"}])
|
|
149
|
-
self.assertEqual(
|
|
150
|
-
ret["report"],
|
|
151
|
-
[
|
|
152
|
-
{},
|
|
153
|
-
{"id": 0},
|
|
154
|
-
{"id": 1},
|
|
155
|
-
{"id": 2},
|
|
156
|
-
{"id": 3},
|
|
157
|
-
{"id": 4},
|
|
158
|
-
{"id": 5},
|
|
159
|
-
{"id": 6},
|
|
160
|
-
{"id": 7},
|
|
161
|
-
{"id": 8},
|
|
162
|
-
{"id": 9},
|
|
163
|
-
{},
|
|
164
|
-
{"id": 0},
|
|
165
|
-
{"id": 1},
|
|
166
|
-
{"id": 2},
|
|
167
|
-
11,
|
|
168
|
-
],
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
def test_walker_simple_yield(self):
|
|
172
|
-
self.call(
|
|
173
|
-
self.mast,
|
|
174
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
175
|
-
)
|
|
176
|
-
expected = [
|
|
177
|
-
"entry",
|
|
178
|
-
{"id": 0},
|
|
179
|
-
{"id": 1},
|
|
180
|
-
{"id": 2},
|
|
181
|
-
{"id": 3},
|
|
182
|
-
{"id": 4},
|
|
183
|
-
{"id": 5},
|
|
184
|
-
{"id": 6},
|
|
185
|
-
{"id": 7},
|
|
186
|
-
{"id": 8},
|
|
187
|
-
{"id": 9},
|
|
188
|
-
"entry",
|
|
189
|
-
{"id": 0},
|
|
190
|
-
{"id": 10},
|
|
191
|
-
{"id": 1},
|
|
192
|
-
{"id": 11},
|
|
193
|
-
]
|
|
194
|
-
for i in range(16):
|
|
195
|
-
ret = self.call(self.mast, ["walker_run", {"name": "simple_yield"}])
|
|
196
|
-
self.assertEqual(ret["report"][0], expected[i])
|
|
197
|
-
|
|
198
|
-
def test_walker_deep_yield2(self):
|
|
199
|
-
self.call(
|
|
200
|
-
self.mast,
|
|
201
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
202
|
-
)
|
|
203
|
-
ret = self.call(self.mast, ["walker_run", {"name": "deep_yield2"}])
|
|
204
|
-
self.assertEqual(
|
|
205
|
-
ret["report"],
|
|
206
|
-
[
|
|
207
|
-
"entry",
|
|
208
|
-
{},
|
|
209
|
-
{"id": 0},
|
|
210
|
-
{"id": 1},
|
|
211
|
-
{"id": 2},
|
|
212
|
-
{"id": 3},
|
|
213
|
-
{"id": 4},
|
|
214
|
-
{"id": 5},
|
|
215
|
-
{"id": 6},
|
|
216
|
-
{"id": 7},
|
|
217
|
-
{"id": 8},
|
|
218
|
-
{"id": 9},
|
|
219
|
-
"entry",
|
|
220
|
-
{},
|
|
221
|
-
{"id": 0},
|
|
222
|
-
{"id": 10},
|
|
223
|
-
{"id": 1},
|
|
224
|
-
{"id": 11},
|
|
225
|
-
],
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
def test_walker_deep_yield_no_leak(self):
|
|
229
|
-
self.call(
|
|
230
|
-
self.mast,
|
|
231
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
232
|
-
)
|
|
233
|
-
before = self.mast._h.get_object_distribution()
|
|
234
|
-
self.call(self.mast, ["walker_run", {"name": "deep_yield"}])
|
|
235
|
-
self.call(self.mast, ["walker_run", {"name": "deep_yield"}])
|
|
236
|
-
self.call(self.mast, ["walker_run", {"name": "deep_yield"}])
|
|
237
|
-
after = self.mast._h.get_object_distribution()
|
|
238
|
-
after.pop(Node)
|
|
239
|
-
after.pop(Edge)
|
|
240
|
-
self.assertEqual(before, after)
|
|
241
|
-
|
|
242
|
-
def test_walker_simple_yield_skip_test(self):
|
|
243
|
-
self.call(
|
|
244
|
-
self.mast,
|
|
245
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
246
|
-
)
|
|
247
|
-
ret = []
|
|
248
|
-
for i in range(16):
|
|
249
|
-
ret += self.call(
|
|
250
|
-
self.mast, ["walker_run", {"name": "simple_yield_skip_test"}]
|
|
251
|
-
)["report"]
|
|
252
|
-
self.assertEqual(
|
|
253
|
-
ret,
|
|
254
|
-
[
|
|
255
|
-
"entry",
|
|
256
|
-
{},
|
|
257
|
-
"in_node",
|
|
258
|
-
{"id": 0},
|
|
259
|
-
"in_node",
|
|
260
|
-
{"id": 1},
|
|
261
|
-
"in_node",
|
|
262
|
-
{"id": 2},
|
|
263
|
-
"in_node",
|
|
264
|
-
{"id": 3},
|
|
265
|
-
"in_node",
|
|
266
|
-
{"id": 4},
|
|
267
|
-
5,
|
|
268
|
-
{"id": 5},
|
|
269
|
-
5,
|
|
270
|
-
{"id": 6},
|
|
271
|
-
5,
|
|
272
|
-
{"id": 7},
|
|
273
|
-
5,
|
|
274
|
-
{"id": 8},
|
|
275
|
-
5,
|
|
276
|
-
{"id": 9},
|
|
277
|
-
"entry",
|
|
278
|
-
{},
|
|
279
|
-
"in_node",
|
|
280
|
-
{"id": 0},
|
|
281
|
-
"in_node",
|
|
282
|
-
{"id": 10},
|
|
283
|
-
"in_node",
|
|
284
|
-
{"id": 1},
|
|
285
|
-
"in_node",
|
|
286
|
-
{"id": 11},
|
|
287
|
-
],
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
def test_error_reporting_walker_only_actions(self):
|
|
291
|
-
self.call(
|
|
292
|
-
self.mast,
|
|
293
|
-
["sentinel_register", {"code": self.load_jac("walker_yield.jac")}],
|
|
294
|
-
)
|
|
295
|
-
ret = []
|
|
296
|
-
self.call(self.mast, ["walker_run", {"name": "error_walker_action"}])
|
|
297
|
-
ret = self.call(self.mast, ["walker_run", {"name": "error_walker_action"}])
|
|
298
|
-
self.assertIn('cannot execute the statement "disengage ; "', ret["errors"][0])
|
|
299
|
-
|
|
300
|
-
def test_walker_stepping(self):
|
|
301
|
-
self.call(
|
|
302
|
-
self.mast,
|
|
303
|
-
["sentinel_register", {"code": self.load_jac("fam.jac")}],
|
|
304
|
-
)
|
|
305
|
-
ret = self.call(self.mast, ["walker_spawn_create", {"name": "create_fam"}])
|
|
306
|
-
jid = ret["jid"]
|
|
307
|
-
ret = self.call(self.mast, ["walker_prime", {"wlk": jid}])
|
|
308
|
-
ret = self.call(self.mast, ["walker_step", {"wlk": jid}])
|
|
309
|
-
self.log(ret)
|
|
310
|
-
self.assertEqual(len(ret["next_node_ids"]), 2)
|
|
311
|
-
ret = self.call(self.mast, ["walker_step", {"wlk": jid}])
|
|
312
|
-
self.assertEqual(len(ret["next_node_ids"]), 1)
|
|
313
|
-
ret = self.call(self.mast, ["walker_step", {"wlk": jid}])
|
|
314
|
-
self.assertEqual(len(ret["next_node_ids"]), 0)
|
|
315
|
-
ret = self.call(self.mast, ["walker_step", {"wlk": jid}])
|
|
316
|
-
self.assertEqual(len(ret["next_node_ids"]), 0)
|
jaseci/extens/api/user_api.py
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
User API
|
|
3
|
-
"""
|
|
4
|
-
from jaseci.extens.api.interface import Interface
|
|
5
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class UserApi:
|
|
9
|
-
"""
|
|
10
|
-
User APIs for creating users (some functions should be override downstream)
|
|
11
|
-
|
|
12
|
-
These User APIs enable the creation and management of users on a Jaseci machine.
|
|
13
|
-
The creation of a user in this context is synonymous to the creation of a master
|
|
14
|
-
Jaseci object. These APIs are particularly useful when running a Jaseci server
|
|
15
|
-
or cluster in contrast to running JSCTL on the command line. Upon executing JSCTL
|
|
16
|
-
a dummy admin user (super_master) is created and all state is dumped to a session
|
|
17
|
-
file, though any users created during a JSCTL session will indeed be created as
|
|
18
|
-
part of that session's state.
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
@Interface.public_api(cli_args=["name"])
|
|
22
|
-
def user_create(
|
|
23
|
-
self,
|
|
24
|
-
name: str,
|
|
25
|
-
password: str = "",
|
|
26
|
-
global_init: str = "",
|
|
27
|
-
global_init_ctx: dict = {},
|
|
28
|
-
other_fields: dict = {},
|
|
29
|
-
send_email: bool = True,
|
|
30
|
-
):
|
|
31
|
-
"""
|
|
32
|
-
Create a new user (master object)
|
|
33
|
-
|
|
34
|
-
This API is used to create users and optionally set them up with a graph and
|
|
35
|
-
related initialization. In the context of
|
|
36
|
-
JSCTL, any name is sufficient and no additional information is required.
|
|
37
|
-
However, for Jaseci serving (whether it be the official Jaseci server, or a
|
|
38
|
-
custom overloaded server) additional fields are required and should be added
|
|
39
|
-
to the other_fields parameter as per the specifics of the encapsulating server
|
|
40
|
-
requirements. In the case of the official Jaseci server, the name field must
|
|
41
|
-
be a valid email, and a password field must be passed through other_fields.
|
|
42
|
-
A number of other optional parameters can also be passed through other_feilds.
|
|
43
|
-
\\vspace{3mm}\\par
|
|
44
|
-
This single API call can also be used to fully set up and initialize a user
|
|
45
|
-
by leveraging the global_init parameter. When set, this parameter attaches the
|
|
46
|
-
user to the global sentinel, creates a new graph for the user, sets it as the
|
|
47
|
-
active graph, then runs an initialization walker on the root node of this new
|
|
48
|
-
graph. The initialization walker is identified by the name assigned to
|
|
49
|
-
global_init. The default empty string assigned to global_init indicates this
|
|
50
|
-
global setup should not be run.
|
|
51
|
-
|
|
52
|
-
:param name: The user name to create. For Jaseci server this must be a valid
|
|
53
|
-
email address.
|
|
54
|
-
:param global_init: The name of an initialization walker. When set the user is
|
|
55
|
-
linked to the global sentinel and the walker is run on a new active graph
|
|
56
|
-
created for the user.
|
|
57
|
-
:param global_init_ctx: Context to preload for the initialization walker
|
|
58
|
-
:param other_fields: This parameter is used for additional fields required for
|
|
59
|
-
overloaded interfaces. This parameter is not used in JSCTL, but is used
|
|
60
|
-
by Jaseci server for the additional parameters of password, is_activated,
|
|
61
|
-
and is_superuser.
|
|
62
|
-
"""
|
|
63
|
-
ret = {}
|
|
64
|
-
mast = self.user_creator(name, password, other_fields, send_email)
|
|
65
|
-
if type(mast) is dict: # in case of upstream error
|
|
66
|
-
return mast
|
|
67
|
-
ret["user"] = mast.serialize()
|
|
68
|
-
self.seek_committer(mast)
|
|
69
|
-
if len(global_init):
|
|
70
|
-
ret["global_init"] = self.user_global_init(
|
|
71
|
-
mast, global_init, global_init_ctx
|
|
72
|
-
)
|
|
73
|
-
ret["success"] = True
|
|
74
|
-
return ret
|
|
75
|
-
|
|
76
|
-
@Interface.admin_api(cli_args=["name"])
|
|
77
|
-
def user_delete(self, name: str):
|
|
78
|
-
"""
|
|
79
|
-
Delete new user (master object)
|
|
80
|
-
|
|
81
|
-
This API is used to delete a user account.
|
|
82
|
-
|
|
83
|
-
:param name: The user name to delete. For Jaseci server this must
|
|
84
|
-
be a valid email address.
|
|
85
|
-
|
|
86
|
-
"""
|
|
87
|
-
ret = {}
|
|
88
|
-
ret["success"] = self.user_destroyer(name)
|
|
89
|
-
if not ret["success"]:
|
|
90
|
-
ret["status_code"] = 400
|
|
91
|
-
return ret
|
|
92
|
-
|
|
93
|
-
@Interface.private_api(cli_args=["name"])
|
|
94
|
-
def user_deleteself(self):
|
|
95
|
-
"""
|
|
96
|
-
Delete self (master object)
|
|
97
|
-
|
|
98
|
-
This API is used to delete a user account.
|
|
99
|
-
"""
|
|
100
|
-
ret = {}
|
|
101
|
-
ret["success"] = self.user_destroyer(self.name)
|
|
102
|
-
if not ret["success"]:
|
|
103
|
-
ret["status_code"] = 400
|
|
104
|
-
return ret
|
|
105
|
-
|
|
106
|
-
def user_creator(
|
|
107
|
-
self, name, password: str = "", other_fields: dict = {}, send_email=True
|
|
108
|
-
):
|
|
109
|
-
"""
|
|
110
|
-
Abstraction for user creation for elegant overriding
|
|
111
|
-
"""
|
|
112
|
-
|
|
113
|
-
return JsOrc.master(h=self._h, name=name)
|
|
114
|
-
|
|
115
|
-
def superuser_creator(self, name, password: str = "", other_fields: dict = {}):
|
|
116
|
-
"""
|
|
117
|
-
Abstraction for super user creation for elegant overriding
|
|
118
|
-
"""
|
|
119
|
-
|
|
120
|
-
return JsOrc.super_master(h=self._h, name=name)
|
|
121
|
-
|
|
122
|
-
def user_global_init(
|
|
123
|
-
self,
|
|
124
|
-
mast,
|
|
125
|
-
global_init: str = "",
|
|
126
|
-
global_init_ctx: dict = {},
|
|
127
|
-
):
|
|
128
|
-
"""
|
|
129
|
-
Create a master instance and return root node master object
|
|
130
|
-
|
|
131
|
-
other_fields used for additional fields for overloaded interfaces
|
|
132
|
-
(i.e., Dango interface)
|
|
133
|
-
"""
|
|
134
|
-
return mast.sentinel_active_global(
|
|
135
|
-
auto_run=global_init,
|
|
136
|
-
auto_run_ctx=global_init_ctx,
|
|
137
|
-
auto_create_graph=True,
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
def user_destroyer(self, name: str):
|
|
141
|
-
"""
|
|
142
|
-
Permanently delete master with given id
|
|
143
|
-
"""
|
|
144
|
-
pass
|