jaseci 1.4.2.6__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.6.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 -118
- jaseci/extens/act_lib/elastic.py +0 -87
- jaseci/extens/act_lib/file.py +0 -77
- jaseci/extens/act_lib/file_handler.py +0 -190
- jaseci/extens/act_lib/internal.py +0 -19
- jaseci/extens/act_lib/jaseci.py +0 -62
- jaseci/extens/act_lib/mail.py +0 -10
- jaseci/extens/act_lib/maths.py +0 -168
- jaseci/extens/act_lib/net.py +0 -192
- jaseci/extens/act_lib/rand.py +0 -83
- jaseci/extens/act_lib/regex.py +0 -85
- jaseci/extens/act_lib/request.py +0 -170
- jaseci/extens/act_lib/std.py +0 -236
- jaseci/extens/act_lib/storage.py +0 -53
- jaseci/extens/act_lib/stripe.py +0 -338
- jaseci/extens/act_lib/task.py +0 -14
- 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 -80
- jaseci/extens/act_lib/vector.py +0 -158
- jaseci/extens/act_lib/webtool.py +0 -29
- jaseci/extens/act_lib/zip.py +0 -34
- jaseci/extens/api/__init__.py +0 -0
- jaseci/extens/api/actions_api.py +0 -171
- jaseci/extens/api/alias_api.py +0 -140
- jaseci/extens/api/architype_api.py +0 -197
- jaseci/extens/api/config_api.py +0 -129
- jaseci/extens/api/global_api.py +0 -85
- jaseci/extens/api/graph_api.py +0 -168
- jaseci/extens/api/health_api.py +0 -21
- jaseci/extens/api/interface.py +0 -269
- jaseci/extens/api/jac_api.py +0 -172
- jaseci/extens/api/jsorc_api.py +0 -317
- jaseci/extens/api/logger_api.py +0 -90
- jaseci/extens/api/master_api.py +0 -134
- jaseci/extens/api/object_api.py +0 -102
- jaseci/extens/api/prometheus_api.py +0 -75
- jaseci/extens/api/queue_api.py +0 -141
- jaseci/extens/api/sentinel_api.py +0 -271
- jaseci/extens/api/share_api.py +0 -64
- jaseci/extens/api/super_api.py +0 -65
- 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 -166
- jaseci/extens/api/walker_api.py +0 -299
- jaseci/extens/api/webhook_api.py +0 -77
- 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 -219
- jaseci/jac/interpreter/interp.py +0 -1784
- jaseci/jac/interpreter/sentinel_interp.py +0 -260
- jaseci/jac/interpreter/tests/__init__.py +0 -0
- jaseci/jac/interpreter/tests/test_interp.py +0 -42
- jaseci/jac/interpreter/walker_interp.py +0 -249
- 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 -151
- 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 -120
- 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 -86
- jaseci/jac/machine/jac_value.py +0 -227
- jaseci/jac/machine/machine_state.py +0 -386
- 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 -365
- jaseci/jsorc/manifests/__init__.py +0 -0
- jaseci/jsorc/manifests/database.yaml +0 -109
- jaseci/jsorc/manifests/elastic.yaml +0 -6029
- 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 -140
- jaseci/jsorc/remote_actions.py +0 -158
- 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 -94
- jaseci/prim/architype.py +0 -90
- jaseci/prim/edge.py +0 -173
- jaseci/prim/element.py +0 -233
- jaseci/prim/graph.py +0 -27
- jaseci/prim/master.py +0 -67
- jaseci/prim/node.py +0 -533
- jaseci/prim/obj_mixins.py +0 -238
- jaseci/prim/sentinel.py +0 -282
- 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 -517
- 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 -169
- 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.6.dist-info/LICENSE +0 -21
- jaseci-1.4.2.6.dist-info/METADATA +0 -39
- jaseci-1.4.2.6.dist-info/RECORD +0 -185
- jaseci-1.4.2.6.dist-info/entry_points.txt +0 -3
- jaseci-1.4.2.6.dist-info/top_level.txt +0 -1
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
3
|
-
import jaseci.tests.jac_test_code as jtc
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class GlobalApiTest(CoreTest):
|
|
7
|
-
"""Unit tests for Jac Global APIs"""
|
|
8
|
-
|
|
9
|
-
fixture_src = __file__
|
|
10
|
-
|
|
11
|
-
def setUp(self):
|
|
12
|
-
super().setUp()
|
|
13
|
-
|
|
14
|
-
self.smast2 = JsOrc.super_master(h=self.smast._h)
|
|
15
|
-
self.smast.sentinel_register(name="test", code=jtc.basic)
|
|
16
|
-
|
|
17
|
-
self.mast2 = JsOrc.master(h=self.mast._h)
|
|
18
|
-
self.mast.sentinel_register(name="test", code=jtc.basic)
|
|
19
|
-
|
|
20
|
-
def tearDown(self):
|
|
21
|
-
super().tearDown()
|
|
22
|
-
|
|
23
|
-
def test_sent_global_active(self):
|
|
24
|
-
"""Test setting global sentinel"""
|
|
25
|
-
api = ["global_sentinel_set", {"snt": None}]
|
|
26
|
-
self.call(self.smast, api)
|
|
27
|
-
api = ["sentinel_active_global", {}]
|
|
28
|
-
self.call(self.smast2, api)
|
|
29
|
-
api = ["sentinel_list", {"detailed": False}]
|
|
30
|
-
r = self.call(self.smast2, api)
|
|
31
|
-
self.assertEqual(len(r), 0)
|
|
32
|
-
api = ["sentinel_active_get", {"detailed": False}]
|
|
33
|
-
r = self.call(self.smast2, api)
|
|
34
|
-
self.assertIn("jid", r.keys())
|
|
35
|
-
self.assertEqual(r["name"], "test")
|
|
36
|
-
api = ["sentinel_list", {"detailed": False}]
|
|
37
|
-
r = self.call(self.smast2, api)
|
|
38
|
-
self.assertEqual(len(r), 0)
|
|
39
|
-
|
|
40
|
-
def test_sent_global_pull(self):
|
|
41
|
-
"""Test setting global sentinel"""
|
|
42
|
-
api = ["global_sentinel_set", {"snt": None}]
|
|
43
|
-
self.call(self.smast, api)
|
|
44
|
-
api = ["sentinel_list", {"detailed": False}]
|
|
45
|
-
r = self.call(self.smast2, api)
|
|
46
|
-
self.assertEqual(len(r), 0)
|
|
47
|
-
api = ["sentinel_pull", {}]
|
|
48
|
-
self.call(self.smast2, api)
|
|
49
|
-
api = ["sentinel_list", {"detailed": False}]
|
|
50
|
-
r = self.call(self.smast2, api)
|
|
51
|
-
self.assertEqual(len(r), 1)
|
|
52
|
-
api = ["sentinel_active_get", {"detailed": False}]
|
|
53
|
-
r = self.call(self.smast2, api)
|
|
54
|
-
self.assertIn("jid", r.keys())
|
|
55
|
-
self.assertEqual(r["name"], "test")
|
|
56
|
-
|
|
57
|
-
def test_global_set_get_delete(self):
|
|
58
|
-
"""Test setting global sentinel"""
|
|
59
|
-
api = ["global_get", {"name": "apple"}]
|
|
60
|
-
r = self.call(self.smast, api)
|
|
61
|
-
self.assertIsNone(r["value"])
|
|
62
|
-
api = ["global_set", {"name": "apple", "value": "56"}]
|
|
63
|
-
r = self.call(self.smast, api)
|
|
64
|
-
api = ["global_get", {"name": "apple"}]
|
|
65
|
-
r = self.call(self.smast2, api)
|
|
66
|
-
self.assertEqual(r["value"], "56")
|
|
67
|
-
api = ["global_delete", {"name": "apple"}]
|
|
68
|
-
r = self.call(self.smast2, api)
|
|
69
|
-
api = ["global_get", {"name": "apple"}]
|
|
70
|
-
r = self.call(self.smast, api)
|
|
71
|
-
self.assertIsNone(r["value"])
|
|
72
|
-
|
|
73
|
-
def test_user_create(self):
|
|
74
|
-
"""Test master create operation"""
|
|
75
|
-
api = ["user_create", {"name": "yo@gmail.com"}]
|
|
76
|
-
r = self.call(self.mast, api)
|
|
77
|
-
self.assertIn("j_type", r["user"])
|
|
78
|
-
self.assertEqual(r["user"]["j_type"], "master")
|
|
79
|
-
|
|
80
|
-
def test_master_create(self):
|
|
81
|
-
"""Test master create operation"""
|
|
82
|
-
api = ["master_create", {"name": "yo@gmail.com"}]
|
|
83
|
-
r = self.call(self.mast, api)
|
|
84
|
-
self.assertIn("j_type", r["user"])
|
|
85
|
-
self.assertEqual(r["user"]["j_type"], "master")
|
|
86
|
-
|
|
87
|
-
def test_master_create_error_out(self):
|
|
88
|
-
"""Test master create operation"""
|
|
89
|
-
api = ["master_create", {"name": "yo@gmail.com"}]
|
|
90
|
-
r = self.call(self.mast, api)
|
|
91
|
-
api = ["master_create", {"name": "yo@gmail.com"}]
|
|
92
|
-
r = self.call(self.mast, api)
|
|
93
|
-
self.assertIn("response", r)
|
|
94
|
-
self.assertIn("already exists", r["response"])
|
|
95
|
-
|
|
96
|
-
def test_master_create_super_limited(self):
|
|
97
|
-
"""Test master create operation"""
|
|
98
|
-
api = ["master_createsuper", {"name": "yo3@gmail.com"}]
|
|
99
|
-
r = self.call(self.mast, api)
|
|
100
|
-
self.assertIn("response", r)
|
|
101
|
-
self.assertIn("not a valid", r["response"])
|
|
102
|
-
|
|
103
|
-
def test_master_create_linked_super_master_create(self):
|
|
104
|
-
"""Test master create operation"""
|
|
105
|
-
api = ["master_createsuper", {"name": "yo3@gmail.com"}]
|
|
106
|
-
r = self.call(self.smast, api)
|
|
107
|
-
self.assertIn("j_type", r["user"])
|
|
108
|
-
self.assertEqual(r["user"]["j_type"], "super_master")
|
|
109
|
-
|
|
110
|
-
def test_global_sentinel_set_unset(self):
|
|
111
|
-
api = ["global_sentinel_set", {}]
|
|
112
|
-
r = self.call(self.smast, api)
|
|
113
|
-
self.assertIn("response", r)
|
|
114
|
-
self.assertNotIn("error", r)
|
|
115
|
-
api = ["global_sentinel_unset", {}]
|
|
116
|
-
r = self.call(self.smast, api)
|
|
117
|
-
self.assertIn("response", r)
|
|
118
|
-
self.assertNotIn("error", r)
|
|
119
|
-
|
|
120
|
-
def test_global_sentinel_double_unset(self):
|
|
121
|
-
api = ["global_sentinel_set", {}]
|
|
122
|
-
r = self.call(self.smast, api)
|
|
123
|
-
self.assertIn("response", r)
|
|
124
|
-
self.assertNotIn("error", r)
|
|
125
|
-
api = ["global_sentinel_unset", {}]
|
|
126
|
-
r = self.call(self.smast, api)
|
|
127
|
-
self.assertIn("response", r)
|
|
128
|
-
self.assertNotIn("error", r)
|
|
129
|
-
api = ["global_sentinel_unset", {}]
|
|
130
|
-
r = self.call(self.smast, api)
|
|
131
|
-
self.assertIn("response", r)
|
|
132
|
-
self.assertNotIn("error", r)
|
|
133
|
-
|
|
134
|
-
def test_graph_node_set_mem_leak_fix(self):
|
|
135
|
-
api = ["graph_create", {}]
|
|
136
|
-
r = self.call(self.smast, api)
|
|
137
|
-
before = len(self.smast._h.mem)
|
|
138
|
-
jid = r["jid"]
|
|
139
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
140
|
-
r = self.call(self.smast, api)
|
|
141
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
142
|
-
r = self.call(self.smast, api)
|
|
143
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
144
|
-
r = self.call(self.smast, api)
|
|
145
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
146
|
-
r = self.call(self.smast, api)
|
|
147
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
148
|
-
r = self.call(self.smast, api)
|
|
149
|
-
api = ["graph_node_set", {"nd": jid, "ctx": {}}]
|
|
150
|
-
r = self.call(self.smast, api)
|
|
151
|
-
after = len(self.smast._h.mem)
|
|
152
|
-
self.assertEqual(before, after)
|
|
153
|
-
|
|
154
|
-
def test_mem_no_leak_creating_one_node_and_node_set(self):
|
|
155
|
-
mem_state = self.smast._h.mem
|
|
156
|
-
before = len(mem_state)
|
|
157
|
-
self.call(
|
|
158
|
-
self.smast,
|
|
159
|
-
["sentinel_register", {"code": self.load_jac("hello_world.jac")}],
|
|
160
|
-
)
|
|
161
|
-
self.assertEqual(len(mem_state) - before, 8)
|
|
162
|
-
before = len(mem_state)
|
|
163
|
-
r = self.call(
|
|
164
|
-
self.smast,
|
|
165
|
-
["walker_run", {"name": "one_node"}],
|
|
166
|
-
)
|
|
167
|
-
jid = r["report"][0]["jid"]
|
|
168
|
-
self.assertEqual(len(mem_state) - before, 2)
|
|
169
|
-
before = len(mem_state)
|
|
170
|
-
self.call(
|
|
171
|
-
self.smast,
|
|
172
|
-
["graph_node_set", {"nd": jid, "ctx": {"msg": "goodbye world"}}],
|
|
173
|
-
)
|
|
174
|
-
self.assertEqual(len(mem_state) - before, 0)
|
|
175
|
-
r = self.call(
|
|
176
|
-
self.smast,
|
|
177
|
-
["graph_node_get", {"nd": jid}],
|
|
178
|
-
)
|
|
179
|
-
self.assertEqual(r["msg"], "goodbye world")
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class GraphApiTest(CoreTest):
|
|
5
|
-
"""Unit tests for Jac Walker APIs"""
|
|
6
|
-
|
|
7
|
-
fixture_src = __file__
|
|
8
|
-
|
|
9
|
-
def test_graph_depth(self):
|
|
10
|
-
self.call(
|
|
11
|
-
self.mast,
|
|
12
|
-
["sentinel_register", {"code": self.load_jac("fam.jac")}],
|
|
13
|
-
)
|
|
14
|
-
ret = self.call(self.mast, ["walker_run", {"name": "create_fam"}])
|
|
15
|
-
ret = self.call(self.mast, ["graph_get", {}])
|
|
16
|
-
self.assertEqual(len(ret), 9)
|
|
17
|
-
ret = self.call(self.mast, ["graph_get", {"depth": 2}])
|
|
18
|
-
|
|
19
|
-
# old approach will include married edge
|
|
20
|
-
# but it shouldn't since it's considered a 3rd step
|
|
21
|
-
self.assertEqual(len(ret), 5)
|
|
22
|
-
ret = self.call(self.mast, ["graph_get", {"depth": 1}])
|
|
23
|
-
self.assertEqual(len(ret), 1)
|
|
24
|
-
|
|
25
|
-
def test_graph_node_view(self):
|
|
26
|
-
self.call(
|
|
27
|
-
self.mast,
|
|
28
|
-
["sentinel_register", {"code": self.load_jac("fam.jac")}],
|
|
29
|
-
)
|
|
30
|
-
ret = self.call(self.mast, ["walker_run", {"name": "create_fam"}])
|
|
31
|
-
ret = self.call(self.mast, ["graph_get", {}])
|
|
32
|
-
self.assertEqual(len(ret), 9)
|
|
33
|
-
ret = self.call(self.mast, ["graph_node_view", {"show_edges": True}])
|
|
34
|
-
self.assertEqual(len(ret), 5)
|
|
35
|
-
ret = self.call(self.mast, ["graph_node_view", {}])
|
|
36
|
-
self.assertEqual(len(ret), 3)
|
|
37
|
-
|
|
38
|
-
def test_graph_node_view_filters(self):
|
|
39
|
-
self.call(
|
|
40
|
-
self.mast,
|
|
41
|
-
["sentinel_register", {"code": self.load_jac("fam.jac")}],
|
|
42
|
-
)
|
|
43
|
-
ret = self.call(self.mast, ["walker_run", {"name": "create_fam"}])
|
|
44
|
-
ret = self.call(self.mast, ["graph_node_view", {"node_type": "man"}])
|
|
45
|
-
self.assertEqual(len(ret), 2)
|
|
46
|
-
jid = ret[1]["jid"]
|
|
47
|
-
ret = self.call(self.mast, ["graph_node_view", {"nd": jid, "show_edges": True}])
|
|
48
|
-
self.assertEqual(len(ret), 7)
|
|
49
|
-
ret = self.call(
|
|
50
|
-
self.mast,
|
|
51
|
-
[
|
|
52
|
-
"graph_node_view",
|
|
53
|
-
{"nd": jid, "show_edges": False, "edge_type": "married"},
|
|
54
|
-
],
|
|
55
|
-
)
|
|
56
|
-
self.assertEqual(len(ret), 2)
|
|
57
|
-
ret = self.call(
|
|
58
|
-
self.mast,
|
|
59
|
-
[
|
|
60
|
-
"graph_node_view",
|
|
61
|
-
{"nd": jid, "show_edges": True, "edge_type": "married"},
|
|
62
|
-
],
|
|
63
|
-
)
|
|
64
|
-
self.assertEqual(len(ret), 3)
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.log_utils import LimitedSlidingBuffer, parse_logs
|
|
2
|
-
from jaseci.utils.test_core import CoreTest
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class LoggerApiTest(CoreTest):
|
|
6
|
-
fixture_src = __file__
|
|
7
|
-
|
|
8
|
-
logs = [
|
|
9
|
-
"2022-11-26 21:43:55,354 - ERROR - start: Skipping MailService due to initialization failure!",
|
|
10
|
-
"ConnectionRefusedError: [Errno 61] Connection refused",
|
|
11
|
-
]
|
|
12
|
-
|
|
13
|
-
def test_parse_logs(self):
|
|
14
|
-
parsed_logs = parse_logs(self.logs)
|
|
15
|
-
|
|
16
|
-
self.assertEqual(len(parsed_logs), 2)
|
|
17
|
-
|
|
18
|
-
self.assertEqual(parsed_logs[0]["level"], "ERROR")
|
|
19
|
-
self.assertEqual(parsed_logs[1]["level"], None)
|
|
20
|
-
|
|
21
|
-
self.assertEqual(parsed_logs[0]["date"], "2022-11-26 21:43:55")
|
|
22
|
-
self.assertEqual(parsed_logs[1]["date"], None)
|
|
23
|
-
|
|
24
|
-
def test_get_logs(self):
|
|
25
|
-
self.logger_on()
|
|
26
|
-
self.call(
|
|
27
|
-
self.mast,
|
|
28
|
-
["sentinel_register", {"code": self.load_jac("test_logging.jac")}],
|
|
29
|
-
)
|
|
30
|
-
self.logger_off()
|
|
31
|
-
|
|
32
|
-
ret = self.call(self.smast, ["logger_get", {}])
|
|
33
|
-
self.assertGreaterEqual(len(ret), 1)
|
|
34
|
-
self.assertTrue(ret[-1]["log"].endswith("Hello world!"))
|
|
35
|
-
|
|
36
|
-
def test_limited_sliding_buffer(self):
|
|
37
|
-
buffer = LimitedSlidingBuffer(max_size=25)
|
|
38
|
-
buffer.write("Hello world!")
|
|
39
|
-
buffer.write("Hi there!")
|
|
40
|
-
buffer.write("Hello world!")
|
|
41
|
-
buffer.write("Hi there!")
|
|
42
|
-
self.assertEqual(buffer.getvalue(), "ere!Hello world!Hi there!")
|
|
43
|
-
self.assertEqual(buffer.current_size, 25)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ObjectApiTest(CoreTest):
|
|
5
|
-
"""Unit tests for Jac Walker APIs"""
|
|
6
|
-
|
|
7
|
-
fixture_src = __file__
|
|
8
|
-
|
|
9
|
-
def test_object_set(self):
|
|
10
|
-
ret = self.call(
|
|
11
|
-
self.mast,
|
|
12
|
-
[
|
|
13
|
-
"object_set",
|
|
14
|
-
{"obj": self.mast.jid, "ctx": {"name": "MYNEWNAME", "jid": "MYNEWJID"}},
|
|
15
|
-
],
|
|
16
|
-
)
|
|
17
|
-
self.assertEqual(ret["name"], "MYNEWNAME")
|
|
18
|
-
self.assertNotEqual(ret["jid"], "MYNEWJID")
|
|
19
|
-
self.assertEqual(self.mast.name, "MYNEWNAME")
|
|
20
|
-
self.assertNotEqual(self.mast.jid, "MYNEWJID")
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class SentinelApiTest(CoreTest):
|
|
5
|
-
"""Unit tests for Jac Walker APIs"""
|
|
6
|
-
|
|
7
|
-
fixture_src = __file__
|
|
8
|
-
|
|
9
|
-
def test_auto_run_when_synced_to_global(self):
|
|
10
|
-
self.call(
|
|
11
|
-
self.smast,
|
|
12
|
-
["sentinel_register", {"code": self.load_jac("hello_world.jac")}],
|
|
13
|
-
)
|
|
14
|
-
self.call(
|
|
15
|
-
self.smast,
|
|
16
|
-
["global_sentinel_set", {}],
|
|
17
|
-
)
|
|
18
|
-
ret = self.call(
|
|
19
|
-
self.mast,
|
|
20
|
-
[
|
|
21
|
-
"sentinel_active_global",
|
|
22
|
-
{
|
|
23
|
-
"auto_run": "init",
|
|
24
|
-
"auto_run_ctx": {"wrld": "jason"},
|
|
25
|
-
"auto_create_graph": True,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
)
|
|
29
|
-
num_gphs = len(self.call(self.mast, ["graph_list", {}]))
|
|
30
|
-
self.assertEqual(ret["auto_run_result"]["report"], ["hello jason!"])
|
|
31
|
-
self.assertEqual(num_gphs, 1)
|
|
32
|
-
|
|
33
|
-
def test_auto_run_when_synced_to_global_multi(self):
|
|
34
|
-
self.call(
|
|
35
|
-
self.smast,
|
|
36
|
-
["sentinel_register", {"code": self.load_jac("hello_world.jac")}],
|
|
37
|
-
)
|
|
38
|
-
self.call(
|
|
39
|
-
self.smast,
|
|
40
|
-
["global_sentinel_set", {}],
|
|
41
|
-
)
|
|
42
|
-
self.call(
|
|
43
|
-
self.mast,
|
|
44
|
-
[
|
|
45
|
-
"sentinel_active_global",
|
|
46
|
-
{
|
|
47
|
-
"auto_run": "init",
|
|
48
|
-
"auto_run_ctx": {"wrld": "jason"},
|
|
49
|
-
"auto_create_graph": True,
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
)
|
|
53
|
-
ret = self.call(
|
|
54
|
-
self.mast,
|
|
55
|
-
[
|
|
56
|
-
"sentinel_active_global",
|
|
57
|
-
{
|
|
58
|
-
"auto_run": "init",
|
|
59
|
-
"auto_run_ctx": {"wrld": "jason"},
|
|
60
|
-
"auto_create_graph": True,
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
)
|
|
64
|
-
num_gphs = len(self.call(self.mast, ["graph_list", {}]))
|
|
65
|
-
self.assertEqual(ret["auto_run_result"]["report"], ["hello jason!"])
|
|
66
|
-
self.assertEqual(num_gphs, 2)
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class UncommonImplementationTest(CoreTest):
|
|
5
|
-
"""Unit tests for Uncommon Implementaion APIs"""
|
|
6
|
-
|
|
7
|
-
fixture_src = __file__
|
|
8
|
-
|
|
9
|
-
def test_overrided_action_ability(self):
|
|
10
|
-
self.call(
|
|
11
|
-
self.smast,
|
|
12
|
-
["sentinel_register", {"code": self.load_jac("action_override.jac")}],
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
reports = self.call(self.smast, ["walker_run", {"name": "check"}])["report"]
|
|
16
|
-
keys = [
|
|
17
|
-
"log",
|
|
18
|
-
"out",
|
|
19
|
-
"js_input",
|
|
20
|
-
"input",
|
|
21
|
-
"js_round",
|
|
22
|
-
"round",
|
|
23
|
-
"err",
|
|
24
|
-
"sleep",
|
|
25
|
-
"sort_by_col",
|
|
26
|
-
"time_now",
|
|
27
|
-
"set_global",
|
|
28
|
-
"get_global",
|
|
29
|
-
"actload_local",
|
|
30
|
-
"actload_remote",
|
|
31
|
-
"actload_module",
|
|
32
|
-
"destroy_global",
|
|
33
|
-
"set_perms",
|
|
34
|
-
"get_perms",
|
|
35
|
-
"grant_perms",
|
|
36
|
-
"revoke_perms",
|
|
37
|
-
"get_report",
|
|
38
|
-
"clear_report",
|
|
39
|
-
"log_activity",
|
|
40
|
-
]
|
|
41
|
-
for key in keys:
|
|
42
|
-
# node tester - testing first report: std should be the default
|
|
43
|
-
self.assertIsInstance(reports[0][key], dict)
|
|
44
|
-
self.assertEqual(reports[0][key]["name"], f"std.{key}")
|
|
45
|
-
self.assertEqual(reports[0][key]["kind"], "ability")
|
|
46
|
-
|
|
47
|
-
# walker check - tester report: std should be the default
|
|
48
|
-
self.assertIsInstance(reports[3][key], dict)
|
|
49
|
-
self.assertEqual(reports[3][key]["name"], f"std.{key}")
|
|
50
|
-
self.assertEqual(reports[3][key]["kind"], "ability")
|
|
51
|
-
|
|
52
|
-
# node tester - testing after std.set_global = 1
|
|
53
|
-
# all actions should be the same except std.set_global
|
|
54
|
-
if key != "set_global":
|
|
55
|
-
self.assertIsInstance(reports[1][key], dict)
|
|
56
|
-
self.assertEqual(reports[1][key]["name"], f"std.{key}")
|
|
57
|
-
self.assertEqual(reports[1][key]["kind"], "ability")
|
|
58
|
-
|
|
59
|
-
self.assertIsInstance(reports[1]["set_global"], int)
|
|
60
|
-
self.assertEqual(reports[1]["set_global"], 1)
|
|
61
|
-
|
|
62
|
-
# node tester - testing third report: std set to 1
|
|
63
|
-
self.assertEqual(reports[2], 1)
|
|
64
|
-
|
|
65
|
-
def test_node_ability_from_global_sentinel(self):
|
|
66
|
-
self.call(self.mast, ["graph_create", {}])
|
|
67
|
-
|
|
68
|
-
self.call(
|
|
69
|
-
self.smast,
|
|
70
|
-
["sentinel_register", {"code": self.load_jac("uncommon_impl.jac")}],
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
self.call(self.smast, ["global_sentinel_set", {}])
|
|
74
|
-
self.call(self.mast, ["sentinel_active_global", {}])
|
|
75
|
-
|
|
76
|
-
res = self.call(self.smast, ["walker_run", {"name": "check_ability"}])
|
|
77
|
-
self.assertEqual("super_master", res["report"][0]["j_type"])
|
|
78
|
-
self.assertEqual([], res["report"][1])
|
|
79
|
-
|
|
80
|
-
# since admin already create `with_ability` node on init,
|
|
81
|
-
# it should not have `inner_node`
|
|
82
|
-
res = self.call(self.smast, ["walker_run", {"name": "check_ability"}])
|
|
83
|
-
self.assertEqual("super_master", res["report"][0]["j_type"])
|
|
84
|
-
self.assertEqual(0, len(res["report"][1]))
|
|
85
|
-
|
|
86
|
-
# users should be able to access their inner nodes inside ability
|
|
87
|
-
res = self.call(self.mast, ["walker_run", {"name": "check_ability"}])
|
|
88
|
-
# before it will return the owner of the sentinel which is the super_master
|
|
89
|
-
self.assertEqual("master", res["report"][0]["j_type"])
|
|
90
|
-
self.assertEqual(1, len(res["report"][1]))
|
|
91
|
-
|
|
92
|
-
def test_existing_node_in_graph_but_not_in_sentinel(self):
|
|
93
|
-
self.call(
|
|
94
|
-
self.smast,
|
|
95
|
-
["sentinel_register", {"code": self.load_jac("with_node_b.jac")}],
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
self.call(
|
|
99
|
-
self.smast,
|
|
100
|
-
["sentinel_register", {"code": self.load_jac("without_node_b.jac")}],
|
|
101
|
-
)
|
|
102
|
-
|
|
103
|
-
res = self.call(self.smast, ["walker_run", {"name": "init"}])
|
|
104
|
-
|
|
105
|
-
self.assertTrue(res["success"])
|
|
106
|
-
self.assertEqual(1, len(res["report"]))
|
|
107
|
-
self.assertTrue("a", len(res["report"][0]["name"]))
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
from jaseci.utils.test_core import CoreTest
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class UserApiTest(CoreTest):
|
|
5
|
-
"""Unit tests for Jac Walker APIs"""
|
|
6
|
-
|
|
7
|
-
fixture_src = __file__
|
|
8
|
-
|
|
9
|
-
def test_user_create_global_init(self):
|
|
10
|
-
self.call(
|
|
11
|
-
self.smast,
|
|
12
|
-
["sentinel_register", {"code": self.load_jac("hello_world.jac")}],
|
|
13
|
-
)
|
|
14
|
-
self.call(
|
|
15
|
-
self.smast,
|
|
16
|
-
["global_sentinel_set", {}],
|
|
17
|
-
)
|
|
18
|
-
ret = self.call(
|
|
19
|
-
self.mast,
|
|
20
|
-
[
|
|
21
|
-
"user_create",
|
|
22
|
-
{
|
|
23
|
-
"name": "joe",
|
|
24
|
-
"global_init": "init",
|
|
25
|
-
"global_init_ctx": {"wrld": "jason"},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
)
|
|
29
|
-
self.assertEqual(
|
|
30
|
-
ret["global_init"]["auto_run_result"]["report"], ["hello jason!"]
|
|
31
|
-
)
|
|
32
|
-
self.assertEqual(ret["user"]["name"], "joe")
|