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
jaseci/tests/test_jac.py
DELETED
|
@@ -1,824 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from unittest import TestCase
|
|
3
|
-
|
|
4
|
-
from antlr4 import CommonTokenStream, InputStream
|
|
5
|
-
|
|
6
|
-
import jaseci.jsorc.live_actions as lact
|
|
7
|
-
import jaseci.tests.jac_test_code as jtc
|
|
8
|
-
from jaseci.prim.sentinel import Sentinel
|
|
9
|
-
from jaseci.prim.graph import Graph
|
|
10
|
-
from jaseci.jac.jac_parse.jacLexer import jacLexer
|
|
11
|
-
from jaseci.jac.jac_parse.jacParser import jacParser
|
|
12
|
-
from jaseci.jsorc.jsorc import JsOrc
|
|
13
|
-
from jaseci.utils.utils import TestCaseHelper
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class JacTests(TestCaseHelper, TestCase):
|
|
17
|
-
"""Unit tests for Jac language"""
|
|
18
|
-
|
|
19
|
-
def setUp(self):
|
|
20
|
-
super().setUp()
|
|
21
|
-
|
|
22
|
-
def tearDown(self):
|
|
23
|
-
super().tearDown()
|
|
24
|
-
|
|
25
|
-
def test_antlr4_parsing_lifelogify(self):
|
|
26
|
-
"""Basic test of jac grammar with lifelogify program"""
|
|
27
|
-
input_stream = InputStream(jtc.prog1)
|
|
28
|
-
lexer = jacLexer(input_stream)
|
|
29
|
-
stream = CommonTokenStream(lexer)
|
|
30
|
-
parser = jacParser(stream)
|
|
31
|
-
parser.start()
|
|
32
|
-
self.assertEqual(parser.getNumberOfSyntaxErrors(), 0)
|
|
33
|
-
|
|
34
|
-
def test_sentinel_loading_jac_code(self):
|
|
35
|
-
"""Test the generation of jaseci trees for programs in grammar"""
|
|
36
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
37
|
-
sent.register_code(jtc.prog1)
|
|
38
|
-
self.assertIsNotNone(sent.run_architype("get_gen_day"))
|
|
39
|
-
self.assertIsNotNone(sent.arch_ids.get_obj_by_name("week", kind="node"))
|
|
40
|
-
|
|
41
|
-
def test_sentinel_loading_jac_code_multiple_times(self):
|
|
42
|
-
"""Test registering resets correctly for multiple attempts"""
|
|
43
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
44
|
-
sent.register_code(jtc.prog0)
|
|
45
|
-
num_arch = len(sent.arch_ids)
|
|
46
|
-
sent.register_code(jtc.prog0)
|
|
47
|
-
self.assertEqual(len(sent.arch_ids), num_arch)
|
|
48
|
-
sent.register_code(jtc.prog0)
|
|
49
|
-
self.assertEqual(len(sent.arch_ids), num_arch)
|
|
50
|
-
|
|
51
|
-
def test_sentinel_register_dep_on_static_errors(self):
|
|
52
|
-
"""Test Jac registering is dependant on correct static/dynamic code"""
|
|
53
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
54
|
-
correct = "node b { has anchor a; }"
|
|
55
|
-
wrong1 = "adfdsf"
|
|
56
|
-
sent.register_code(correct)
|
|
57
|
-
self.assertTrue(sent.is_active)
|
|
58
|
-
sent.register_code(wrong1)
|
|
59
|
-
self.assertFalse(sent.is_active)
|
|
60
|
-
sent.register_code(correct)
|
|
61
|
-
self.assertTrue(sent.is_active)
|
|
62
|
-
sent.register_code(wrong1)
|
|
63
|
-
self.assertFalse(sent.is_active)
|
|
64
|
-
sent.register_code(correct)
|
|
65
|
-
self.assertTrue(sent.is_active)
|
|
66
|
-
|
|
67
|
-
def test_sentinel_loading_arhitype(self):
|
|
68
|
-
"""Test the generation of jaseci trees for programs in grammar"""
|
|
69
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
70
|
-
sent.register_code(jtc.prog1)
|
|
71
|
-
self.assertGreater(
|
|
72
|
-
len(sent.arch_ids.get_obj_by_name("month", kind="node").code_ir), 5
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
def test_sentinel_running_basic_walker(self):
|
|
76
|
-
"""Test the execution of a basic walker building graph"""
|
|
77
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
78
|
-
sent.register_code(jtc.prog1)
|
|
79
|
-
test_node = sent.arch_ids.get_obj_by_name("life", kind="node").run()
|
|
80
|
-
test_walker = sent.run_architype("get_gen_day")
|
|
81
|
-
test_walker.prime(test_node)
|
|
82
|
-
test_walker.context["date"] = "2010-08-03T03:00:00.000000"
|
|
83
|
-
test_walker.run()
|
|
84
|
-
self.assertEqual(len(test_node.outbound_nodes()), 1)
|
|
85
|
-
self.assertEqual(test_node.outbound_nodes()[0].name, "year")
|
|
86
|
-
self.assertEqual(
|
|
87
|
-
test_node.outbound_nodes()[0].outbound_nodes()[0].outbound_nodes()[0].name,
|
|
88
|
-
"week",
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
def test_sentinel_setp_running_walker(self):
|
|
92
|
-
"""Test the execution of a basic walker building graph"""
|
|
93
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
94
|
-
sent.register_code(jtc.prog1)
|
|
95
|
-
test_node = sent.arch_ids.get_obj_by_name("life", kind="node").run()
|
|
96
|
-
test_walker = sent.run_architype("get_gen_day")
|
|
97
|
-
test_walker.prime(test_node)
|
|
98
|
-
test_walker.context["date"] = "2010-08-03T03:00:00.000000"
|
|
99
|
-
self.assertEqual(len(test_node.outbound_nodes()), 0)
|
|
100
|
-
next = test_walker.step()
|
|
101
|
-
self.assertEqual(test_node.outbound_nodes()[0], next)
|
|
102
|
-
next = test_walker.step()
|
|
103
|
-
next = test_walker.step()
|
|
104
|
-
self.assertEqual(next.name, "week")
|
|
105
|
-
next = test_walker.step()
|
|
106
|
-
next = test_walker.step()
|
|
107
|
-
self.assertEqual(test_walker.current_step, 5)
|
|
108
|
-
self.assertTrue(next)
|
|
109
|
-
next = test_walker.step()
|
|
110
|
-
self.assertFalse(next)
|
|
111
|
-
|
|
112
|
-
def test_walker_writes_through_no_data_gain_loss_on_contexts(self):
|
|
113
|
-
"""
|
|
114
|
-
Test that no loss or gain of data on second trak on second trek
|
|
115
|
-
"""
|
|
116
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
117
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
118
|
-
sent.register_code(jtc.prog1)
|
|
119
|
-
test_node = sent.arch_ids.get_obj_by_name("life", kind="node").run()
|
|
120
|
-
test_walker = sent.run_architype("get_gen_day")
|
|
121
|
-
test_walker.prime(test_node)
|
|
122
|
-
test_walker.context["date"] = "2010-08-03T03:00:00.000000"
|
|
123
|
-
self.assertEqual(test_walker.context["date"], "2010-08-03T03:00:00.000000")
|
|
124
|
-
test_walker.run()
|
|
125
|
-
after_gen = len(gph._h.mem)
|
|
126
|
-
test_walker.prime(test_node)
|
|
127
|
-
test_walker.context["date"] = "2010-08-03T03:00:00.000000"
|
|
128
|
-
test_walker.run()
|
|
129
|
-
after_track = len(gph._h.mem)
|
|
130
|
-
# Tests that more items were created the first time through
|
|
131
|
-
self.assertEqual(after_gen, after_track)
|
|
132
|
-
|
|
133
|
-
def test_arch_ids_generate_node_bound_objects_scalably(self):
|
|
134
|
-
"""
|
|
135
|
-
Test that arch_ids in sents bind contents to actual nodes
|
|
136
|
-
scalably (node contexts dont get deleted when arch_ids deleted)
|
|
137
|
-
"""
|
|
138
|
-
lact.load_local_actions(os.path.dirname(__file__) + "/infer.py")
|
|
139
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
140
|
-
sent.register_code(jtc.prog1)
|
|
141
|
-
test_node = sent.arch_ids.get_obj_by_name("life", kind="node").run()
|
|
142
|
-
test_walker = sent.run_architype("get_gen_day")
|
|
143
|
-
test_walker.prime(test_node)
|
|
144
|
-
test_walker.context["date"] = "2010-08-03T03:00:00.000000"
|
|
145
|
-
self.assertEqual(test_walker.context["date"], "2010-08-03T03:00:00.000000")
|
|
146
|
-
test_walker.run()
|
|
147
|
-
|
|
148
|
-
year_node = test_node.outbound_nodes()[0]
|
|
149
|
-
before_del = year_node.context["year"]
|
|
150
|
-
sent.register_code(jtc.prog1)
|
|
151
|
-
after_del = year_node.context["year"]
|
|
152
|
-
self.assertEqual(before_del, after_del)
|
|
153
|
-
|
|
154
|
-
def test_sent_loads_complex_walker_and_arch(self):
|
|
155
|
-
"""Test loading attributes of arch and walkers"""
|
|
156
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
157
|
-
sent.register_code(jtc.prog1)
|
|
158
|
-
test_node = sent.arch_ids.get_obj_by_name("testnode", kind="node").run()
|
|
159
|
-
test_walker = sent.run_architype("testwalk")
|
|
160
|
-
test_walker.prime(test_node)
|
|
161
|
-
test_walker.run()
|
|
162
|
-
self.assertEqual(test_node.context["c"], '43Yeah \n"fools"!')
|
|
163
|
-
|
|
164
|
-
def test_availabilty_of_global_functions(self):
|
|
165
|
-
"""Test preset function loading"""
|
|
166
|
-
from jaseci.jac.machine.jac_scope import JacScope
|
|
167
|
-
|
|
168
|
-
JacScope(None, None)
|
|
169
|
-
from jaseci.jac.machine.jac_scope import get_global_actions
|
|
170
|
-
|
|
171
|
-
self.assertGreater(len(get_global_actions()), 5)
|
|
172
|
-
|
|
173
|
-
def test_multiple_edged_between_nodes_work(self):
|
|
174
|
-
"""Test that multiple edges between the same two nodes are allowed"""
|
|
175
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
176
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
177
|
-
sent.register_code(jtc.edgey)
|
|
178
|
-
test_walker = sent.run_architype("init")
|
|
179
|
-
test_walker.prime(gph)
|
|
180
|
-
test_walker.run()
|
|
181
|
-
edges = list(gph.get_all_architypes()[1].values())
|
|
182
|
-
self.assertEqual(len(edges), 3)
|
|
183
|
-
edge_names = [edges[0].name, edges[1].name, edges[2].name]
|
|
184
|
-
self.assertIn("generic", edge_names)
|
|
185
|
-
self.assertIn("apple", edge_names)
|
|
186
|
-
self.assertIn("banana", edge_names)
|
|
187
|
-
|
|
188
|
-
def test_multiple_edged_between_nodes_delete_all(self):
|
|
189
|
-
"""Test that multiple edges deleted correctly if delete all"""
|
|
190
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
191
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
192
|
-
sent.register_code(jtc.edgey2)
|
|
193
|
-
test_walker = sent.run_architype("init")
|
|
194
|
-
test_walker.prime(gph)
|
|
195
|
-
test_walker.run()
|
|
196
|
-
edges = gph.get_all_architypes()[1].values()
|
|
197
|
-
self.assertEqual(len(edges), 0)
|
|
198
|
-
|
|
199
|
-
def test_multiple_edged_between_nodes_delete_all_specific(self):
|
|
200
|
-
"""Test that multiple edges deleted correctly if delete all"""
|
|
201
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
202
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
203
|
-
sent.register_code(jtc.edgey2b)
|
|
204
|
-
test_walker = sent.run_architype("init")
|
|
205
|
-
test_walker.prime(gph)
|
|
206
|
-
test_walker.run()
|
|
207
|
-
edges = gph.get_all_architypes()[1].values()
|
|
208
|
-
self.assertEqual(len(edges), 1)
|
|
209
|
-
|
|
210
|
-
def test_multiple_edged_between_nodes_delete_all_labeled(self):
|
|
211
|
-
"""Test that multiple edges deleted correctly if delete all"""
|
|
212
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
213
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
214
|
-
sent.register_code(jtc.edgey2c)
|
|
215
|
-
test_walker = sent.run_architype("init")
|
|
216
|
-
test_walker.prime(gph)
|
|
217
|
-
test_walker.run()
|
|
218
|
-
edges = gph.get_all_architypes()[1].values()
|
|
219
|
-
self.assertEqual(len(edges), 3)
|
|
220
|
-
|
|
221
|
-
def test_multiple_edged_between_nodes_delete_filtered(self):
|
|
222
|
-
"""Test that multiple edges deleted correctly if delete filtered"""
|
|
223
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
224
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
225
|
-
sent.register_code(jtc.edgey3)
|
|
226
|
-
test_walker = sent.run_architype("init")
|
|
227
|
-
test_walker.prime(gph)
|
|
228
|
-
test_walker.run()
|
|
229
|
-
edges = gph.get_all_architypes()[1].values()
|
|
230
|
-
self.assertEqual(len(edges), 5)
|
|
231
|
-
|
|
232
|
-
def test_generic_can_be_used_to_specify_generic_edges(self):
|
|
233
|
-
"""Test that generic edge tag works"""
|
|
234
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
235
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
236
|
-
sent.register_code(jtc.edgey4)
|
|
237
|
-
test_walker = sent.run_architype("init")
|
|
238
|
-
test_walker.prime(gph)
|
|
239
|
-
test_walker.run()
|
|
240
|
-
edges = gph.get_all_architypes()[1].values()
|
|
241
|
-
self.assertEqual(len(edges), 2)
|
|
242
|
-
|
|
243
|
-
def test_can_disconnect_multi_nodes_simultaneously(self):
|
|
244
|
-
"""Test disconnecting mutilpe nodes"""
|
|
245
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
246
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
247
|
-
sent.register_code(jtc.edgey5)
|
|
248
|
-
test_walker = sent.run_architype("init")
|
|
249
|
-
test_walker.prime(gph)
|
|
250
|
-
test_walker.run()
|
|
251
|
-
edges = gph.get_all_architypes()[1].values()
|
|
252
|
-
self.assertEqual(len(edges), 2)
|
|
253
|
-
|
|
254
|
-
def test_can_connect_multi_nodes_simultaneously(self):
|
|
255
|
-
"""Test connecting mutilpe nodes"""
|
|
256
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
257
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
258
|
-
sent.register_code(jtc.edgey6)
|
|
259
|
-
test_walker = sent.run_architype("init")
|
|
260
|
-
test_walker.prime(gph)
|
|
261
|
-
test_walker.run()
|
|
262
|
-
edges = gph.get_all_architypes()[1].values()
|
|
263
|
-
self.assertEqual(len(edges), 4)
|
|
264
|
-
|
|
265
|
-
def test_can_disconnect_multi_nodes_advanced(self):
|
|
266
|
-
"""Test disconnecting mutilpe nodes advanced"""
|
|
267
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
268
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
269
|
-
sent.register_code(jtc.edgey7)
|
|
270
|
-
test_walker = sent.run_architype("init")
|
|
271
|
-
test_walker.prime(gph)
|
|
272
|
-
test_walker.run()
|
|
273
|
-
edges = gph.get_all_architypes()[1].values()
|
|
274
|
-
self.assertEqual(len(edges), 3)
|
|
275
|
-
|
|
276
|
-
def test_accessing_edges_basic(self):
|
|
277
|
-
"""Test accessing Edges"""
|
|
278
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
279
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
280
|
-
sent.register_code(jtc.edge_access)
|
|
281
|
-
test_walker = sent.run_architype("init")
|
|
282
|
-
test_walker.prime(gph)
|
|
283
|
-
test_walker.run()
|
|
284
|
-
edges = list(gph.get_all_architypes()[1].values())
|
|
285
|
-
if edges[0].name == "apple":
|
|
286
|
-
self.assertEqual(edges[0].context["v1"], 7)
|
|
287
|
-
self.assertEqual(edges[1].context["x1"], 8)
|
|
288
|
-
else:
|
|
289
|
-
self.assertEqual(edges[1].context["v1"], 7)
|
|
290
|
-
self.assertEqual(edges[0].context["x1"], 8)
|
|
291
|
-
|
|
292
|
-
def test_has_assign(self):
|
|
293
|
-
"""Test assignment on definition"""
|
|
294
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
295
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
296
|
-
sent.register_code(jtc.has_assign)
|
|
297
|
-
test_walker = sent.run_architype("init")
|
|
298
|
-
test_walker.prime(gph)
|
|
299
|
-
test_walker.run()
|
|
300
|
-
nodes = gph.get_all_architypes()[0].values()
|
|
301
|
-
self.assertEqual(len(nodes), 3)
|
|
302
|
-
num = 0
|
|
303
|
-
for i in nodes:
|
|
304
|
-
if i.name == "testnode":
|
|
305
|
-
self.assertEqual(i.context["a"], 8)
|
|
306
|
-
num += 1
|
|
307
|
-
self.assertEqual(num, 2)
|
|
308
|
-
|
|
309
|
-
def test_global_get_set(self):
|
|
310
|
-
"""Test assignment on definition"""
|
|
311
|
-
mast = JsOrc.super_master()
|
|
312
|
-
sent = Sentinel(m_id=mast.jid, h=mast._h)
|
|
313
|
-
gph = Graph(m_id=mast.jid, h=mast._h)
|
|
314
|
-
sent.register_code(jtc.set_get_global)
|
|
315
|
-
test_walker = sent.run_architype("setter")
|
|
316
|
-
test_walker.prime(gph)
|
|
317
|
-
test_walker.run()
|
|
318
|
-
test_walker2 = sent.run_architype("getter")
|
|
319
|
-
test_walker2.prime(gph)
|
|
320
|
-
test_walker2.run()
|
|
321
|
-
self.assertEqual(test_walker2.context["a"], 59)
|
|
322
|
-
|
|
323
|
-
def test_global_set_requires_admin(self):
|
|
324
|
-
"""Test assignment on definition"""
|
|
325
|
-
mast = JsOrc.master()
|
|
326
|
-
sent = Sentinel(m_id=mast.jid, h=mast._h)
|
|
327
|
-
gph = Graph(m_id=mast.jid, h=mast._h)
|
|
328
|
-
sent.register_code(jtc.set_get_global2)
|
|
329
|
-
test_walker = sent.run_architype("setter")
|
|
330
|
-
test_walker.prime(gph)
|
|
331
|
-
test_walker.run()
|
|
332
|
-
test_walker2 = sent.run_architype("getter")
|
|
333
|
-
test_walker2.prime(gph)
|
|
334
|
-
test_walker2.run()
|
|
335
|
-
self.assertEqual(test_walker2.context["a"], None)
|
|
336
|
-
|
|
337
|
-
def test_sentinel_version_label(self):
|
|
338
|
-
"""Test sentinel version labeling"""
|
|
339
|
-
mast = JsOrc.master()
|
|
340
|
-
sent = Sentinel(m_id=mast.jid, h=mast._h)
|
|
341
|
-
sent.register_code(jtc.version_label)
|
|
342
|
-
self.assertEqual(sent.version, "alpha-1.0")
|
|
343
|
-
|
|
344
|
-
def test_visibility_builtins(self):
|
|
345
|
-
"""Test builtins to see into nodes and edges"""
|
|
346
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
347
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
348
|
-
sent.register_code(jtc.visibility_builtins)
|
|
349
|
-
test_walker = sent.run_architype("init")
|
|
350
|
-
test_walker.prime(gph)
|
|
351
|
-
test_walker.run()
|
|
352
|
-
self.assertEqual(2, len(test_walker.report[0][0].keys()))
|
|
353
|
-
self.assertGreaterEqual(len(test_walker.report[0][1].keys()), 6)
|
|
354
|
-
self.assertLess(len(test_walker.report[0][1].keys()), 14)
|
|
355
|
-
self.assertGreaterEqual(len(test_walker.report[0][2].keys()), 13)
|
|
356
|
-
|
|
357
|
-
def test_spawn_ctx_for_edges_nodes(self):
|
|
358
|
-
"""Test builtins to see into nodes and edges"""
|
|
359
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
360
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
361
|
-
sent.register_code(jtc.spawn_ctx_edge_node)
|
|
362
|
-
test_walker = sent.run_architype("init")
|
|
363
|
-
test_walker.prime(gph)
|
|
364
|
-
test_walker.run()
|
|
365
|
-
self.assertEqual(test_walker.report[0]["age"], 32)
|
|
366
|
-
self.assertEqual(test_walker.report[1]["meeting_place"], "college")
|
|
367
|
-
self.assertEqual(test_walker.report[2]["name"], "Jane")
|
|
368
|
-
self.assertEqual(test_walker.report[3]["kind"], "sister")
|
|
369
|
-
|
|
370
|
-
def test_filter_ctx_for_edges_nodes(self):
|
|
371
|
-
"""Test builtins to see into nodes and edges"""
|
|
372
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
373
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
374
|
-
sent.register_code(jtc.filter_ctx_edge_node)
|
|
375
|
-
test_walker = sent.run_architype("init")
|
|
376
|
-
test_walker.prime(gph)
|
|
377
|
-
test_walker.run()
|
|
378
|
-
self.assertEqual(test_walker.report[0]["age"], 30)
|
|
379
|
-
self.assertEqual(len(test_walker.report[1]), 0)
|
|
380
|
-
|
|
381
|
-
def test_null_handling(self):
|
|
382
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
383
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
384
|
-
sent.register_code(jtc.null_handleing)
|
|
385
|
-
test_walker = sent.run_architype("init")
|
|
386
|
-
test_walker.prime(gph)
|
|
387
|
-
test_walker.run()
|
|
388
|
-
self.assertEqual(test_walker.report[0], True)
|
|
389
|
-
self.assertEqual(test_walker.report[1], False)
|
|
390
|
-
self.assertEqual(test_walker.report[2], True)
|
|
391
|
-
self.assertEqual(test_walker.report[3], False)
|
|
392
|
-
|
|
393
|
-
def test_bool_type_convert(self):
|
|
394
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
395
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
396
|
-
sent.register_code(jtc.bool_type_convert)
|
|
397
|
-
test_walker = sent.run_architype("init")
|
|
398
|
-
test_walker.prime(gph)
|
|
399
|
-
test_walker.run()
|
|
400
|
-
self.assertEqual(test_walker.report[0], True)
|
|
401
|
-
self.assertEqual(True, test_walker.report[1]["name"])
|
|
402
|
-
|
|
403
|
-
def test_typecasts(self):
|
|
404
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
405
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
406
|
-
sent.register_code(jtc.typecasts)
|
|
407
|
-
test_walker = sent.run_architype("init")
|
|
408
|
-
test_walker.prime(gph)
|
|
409
|
-
test_walker.run()
|
|
410
|
-
self.assertEqual(test_walker.report[0], 7.6)
|
|
411
|
-
self.assertEqual(test_walker.report[1], 7)
|
|
412
|
-
self.assertEqual(test_walker.report[2], "7.6")
|
|
413
|
-
self.assertEqual(test_walker.report[3], True)
|
|
414
|
-
self.assertEqual(test_walker.report[4], 7.0)
|
|
415
|
-
self.assertEqual(test_walker.report[5], "Types comes back correct")
|
|
416
|
-
|
|
417
|
-
def test_typecast_error(self):
|
|
418
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
419
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
420
|
-
sent.register_code(jtc.typecasts_error)
|
|
421
|
-
test_walker = sent.run_architype("init")
|
|
422
|
-
test_walker.prime(gph)
|
|
423
|
-
test_walker.run()
|
|
424
|
-
self.assertEqual(
|
|
425
|
-
"basic:init - line 9, col 25 - rule any_type - Cannot get edges from 7.6. Type JAC_TYPE.FLOAT invalid",
|
|
426
|
-
test_walker.runtime_errors[0],
|
|
427
|
-
)
|
|
428
|
-
self.assertIn(
|
|
429
|
-
"Invalid cast of JAC_TYPE.STR to JAC_TYPE.INT",
|
|
430
|
-
test_walker.runtime_errors[1],
|
|
431
|
-
)
|
|
432
|
-
|
|
433
|
-
def test_filter_on_context(self):
|
|
434
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
435
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
436
|
-
sent.register_code(jtc.filter_on_context)
|
|
437
|
-
test_walker = sent.run_architype("init")
|
|
438
|
-
test_walker.prime(gph)
|
|
439
|
-
test_walker.run()
|
|
440
|
-
self.assertEqual({"yo": "Yeah i said"}, test_walker.report[0][0])
|
|
441
|
-
self.assertNotIn("name", test_walker.report[0][1].keys())
|
|
442
|
-
self.assertIn("name", test_walker.report[0][2].keys())
|
|
443
|
-
|
|
444
|
-
def test_string_manipulation(self):
|
|
445
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
446
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
447
|
-
sent.register_code(jtc.string_manipulation)
|
|
448
|
-
test_walker = sent.run_architype("init")
|
|
449
|
-
test_walker.prime(gph)
|
|
450
|
-
test_walker.run()
|
|
451
|
-
rep = test_walker.report
|
|
452
|
-
self.assertEqual(rep[0], "t")
|
|
453
|
-
self.assertEqual(rep[1], "tin")
|
|
454
|
-
self.assertEqual(rep[2], "sting me ")
|
|
455
|
-
self.assertEqual(rep[3], " TESTING ME ")
|
|
456
|
-
self.assertEqual(rep[4], " testing me ")
|
|
457
|
-
self.assertEqual(rep[5], " Testing Me ")
|
|
458
|
-
self.assertEqual(rep[6], " testing me ")
|
|
459
|
-
self.assertEqual(rep[7], " TeSTING ME ")
|
|
460
|
-
self.assertEqual(rep[8], False)
|
|
461
|
-
self.assertEqual(rep[9], False)
|
|
462
|
-
self.assertEqual(rep[10], False)
|
|
463
|
-
self.assertEqual(rep[11], False)
|
|
464
|
-
self.assertEqual(rep[12], False)
|
|
465
|
-
self.assertEqual(rep[13], False)
|
|
466
|
-
self.assertEqual(rep[14], False)
|
|
467
|
-
self.assertEqual(rep[15], {"a": 5})
|
|
468
|
-
self.assertEqual(rep[16], 2)
|
|
469
|
-
self.assertEqual(rep[17], 5)
|
|
470
|
-
self.assertEqual(rep[18], ["tEsting", "me"])
|
|
471
|
-
self.assertEqual(rep[19], [" t", "sting me "])
|
|
472
|
-
self.assertEqual(rep[20], False)
|
|
473
|
-
self.assertEqual(rep[21], False)
|
|
474
|
-
self.assertEqual(rep[22], " tEsting you ")
|
|
475
|
-
self.assertEqual(rep[23], "tEsting me")
|
|
476
|
-
self.assertEqual(rep[24], "Esting me")
|
|
477
|
-
self.assertEqual(rep[25], "tEsting me ")
|
|
478
|
-
self.assertEqual(rep[26], "sting me ")
|
|
479
|
-
self.assertEqual(rep[27], " tEsting me")
|
|
480
|
-
self.assertEqual(rep[28], " tEsting m")
|
|
481
|
-
self.assertEqual(rep[29], True)
|
|
482
|
-
|
|
483
|
-
def test_list_manipulation(self):
|
|
484
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
485
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
486
|
-
sent.register_code(jtc.list_manipulation)
|
|
487
|
-
test_walker = sent.run_architype("init")
|
|
488
|
-
test_walker.prime(gph)
|
|
489
|
-
test_walker.run()
|
|
490
|
-
rep = test_walker.report
|
|
491
|
-
self.assertEqual(rep[0], [4])
|
|
492
|
-
self.assertEqual(rep[1], [5])
|
|
493
|
-
self.assertEqual(rep[2], [4, 5, 5])
|
|
494
|
-
self.assertEqual(rep[3], [5, 5, 4])
|
|
495
|
-
self.assertEqual(rep[4], [4, 5, 5])
|
|
496
|
-
self.assertEqual(rep[5], 2)
|
|
497
|
-
self.assertEqual(rep[6], [5, 5, 4, 2])
|
|
498
|
-
self.assertEqual(rep[7], [5, "apple", 4, 2])
|
|
499
|
-
self.assertEqual(rep[8], 1)
|
|
500
|
-
self.assertEqual(rep[9], [5, "apple", 4])
|
|
501
|
-
self.assertEqual(rep[10], [])
|
|
502
|
-
|
|
503
|
-
def test_list_reversed(self):
|
|
504
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
505
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
506
|
-
sent.register_code(jtc.list_reversed)
|
|
507
|
-
test_walker = sent.run_architype("init")
|
|
508
|
-
test_walker.prime(gph)
|
|
509
|
-
test_walker.run()
|
|
510
|
-
rep = test_walker.report
|
|
511
|
-
self.assertEqual(rep[0], [7, 2, 4])
|
|
512
|
-
self.assertEqual(rep[1], [4, 2, 7])
|
|
513
|
-
|
|
514
|
-
def test_dict_manipulation(self):
|
|
515
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
516
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
517
|
-
sent.register_code(jtc.dict_manipulation)
|
|
518
|
-
test_walker = sent.run_architype("init")
|
|
519
|
-
test_walker.prime(gph)
|
|
520
|
-
test_walker.run()
|
|
521
|
-
rep = test_walker.report
|
|
522
|
-
self.assertEqual(rep[0], {"four": 4, "five": 5})
|
|
523
|
-
self.assertEqual(rep[1], {"four": 5, "five": 5})
|
|
524
|
-
self.assertEqual(rep[2], [["four", 4], ["five", 5]])
|
|
525
|
-
self.assertEqual(rep[3], ["four", "five"])
|
|
526
|
-
self.assertEqual(rep[4], {"four": 4})
|
|
527
|
-
self.assertEqual(rep[5], [4])
|
|
528
|
-
self.assertEqual(rep[6], {"four": 7})
|
|
529
|
-
self.assertEqual(rep[7], {})
|
|
530
|
-
|
|
531
|
-
def test_string_join(self):
|
|
532
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
533
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
534
|
-
sent.register_code(jtc.string_join)
|
|
535
|
-
test_walker = sent.run_architype("init")
|
|
536
|
-
test_walker.prime(gph)
|
|
537
|
-
test_walker.run()
|
|
538
|
-
rep = test_walker.report
|
|
539
|
-
self.assertEqual(rep[0], "test_me_now")
|
|
540
|
-
|
|
541
|
-
def test_sub_list(self):
|
|
542
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
543
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
544
|
-
sent.register_code(jtc.sub_list)
|
|
545
|
-
test_walker = sent.run_architype("init")
|
|
546
|
-
test_walker.prime(gph)
|
|
547
|
-
test_walker.run()
|
|
548
|
-
rep = test_walker.report
|
|
549
|
-
self.assertEqual(rep[0][0], 5)
|
|
550
|
-
self.assertEqual(rep[0][1], 6)
|
|
551
|
-
self.assertEqual(rep[0][2], 7)
|
|
552
|
-
|
|
553
|
-
def test_destroy_and_misc(self):
|
|
554
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
555
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
556
|
-
sent.register_code(jtc.destroy_and_misc)
|
|
557
|
-
test_walker = sent.run_architype("init")
|
|
558
|
-
test_walker.prime(gph)
|
|
559
|
-
test_walker.run()
|
|
560
|
-
rep = test_walker.report
|
|
561
|
-
self.assertEqual(rep[0], "Josh")
|
|
562
|
-
self.assertEqual(
|
|
563
|
-
rep[1], {"name": None, "age": 32, "birthday": None, "profession": None}
|
|
564
|
-
)
|
|
565
|
-
self.assertEqual(
|
|
566
|
-
rep[2], {"age": 32, "birthday": None, "name": "pete", "profession": None}
|
|
567
|
-
)
|
|
568
|
-
self.assertEqual(rep[3], [1, 3])
|
|
569
|
-
self.assertEqual(rep[4], {"a": "b"})
|
|
570
|
-
self.assertEqual(rep[5], [1, 2, 5, 6, 7, 8, 9])
|
|
571
|
-
self.assertEqual(rep[6], [1, 2, 45, 33, 7, 8, 9])
|
|
572
|
-
self.assertEqual(
|
|
573
|
-
rep[7], {"age": 32, "birthday": None, "name": "pete", "profession": None}
|
|
574
|
-
)
|
|
575
|
-
self.assertEqual(rep[8], True)
|
|
576
|
-
|
|
577
|
-
err = test_walker.runtime_errors
|
|
578
|
-
self.assertEqual(
|
|
579
|
-
err[0],
|
|
580
|
-
"basic:init - line 30, col 0 - rule report_action - Variable not defined - a",
|
|
581
|
-
)
|
|
582
|
-
self.assertEqual(
|
|
583
|
-
err[1],
|
|
584
|
-
"basic:init - line 33, col 0 - rule atom - Creating variable banana in graph element <class 'jaseci.prim.node.Node'> is not allowed, please define",
|
|
585
|
-
)
|
|
586
|
-
|
|
587
|
-
def test_arbitrary_assign_on_element(self):
|
|
588
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
589
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
590
|
-
sent.register_code(jtc.arbitrary_assign_on_element)
|
|
591
|
-
test_walker = sent.run_architype("init")
|
|
592
|
-
test_walker.prime(gph)
|
|
593
|
-
test_walker.run()
|
|
594
|
-
rep = test_walker.report
|
|
595
|
-
self.assertEqual(
|
|
596
|
-
rep[0], {"name": None, "age": None, "birthday": None, "profession": None}
|
|
597
|
-
)
|
|
598
|
-
err = test_walker.runtime_errors
|
|
599
|
-
self.assertEqual(
|
|
600
|
-
err[0],
|
|
601
|
-
"basic:init - line 6, col 0 - rule atom - Creating variable apple in graph element <class 'jaseci.prim.node.Node'> is not allowed, please define",
|
|
602
|
-
)
|
|
603
|
-
|
|
604
|
-
def test_try_else_stmts(self):
|
|
605
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
606
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
607
|
-
sent.register_code(jtc.try_else_stmts)
|
|
608
|
-
test_walker = sent.run_architype("init")
|
|
609
|
-
test_walker.prime(gph)
|
|
610
|
-
test_walker.run()
|
|
611
|
-
rep = test_walker.report
|
|
612
|
-
rep[0].pop("stack_trace", None) # remove stack_trace
|
|
613
|
-
self.assertEqual(
|
|
614
|
-
rep[0],
|
|
615
|
-
{
|
|
616
|
-
"args": ("division by zero",),
|
|
617
|
-
"col": 13,
|
|
618
|
-
"line": 4,
|
|
619
|
-
"mod": "basic",
|
|
620
|
-
"msg": "division by zero",
|
|
621
|
-
"type": "ZeroDivisionError",
|
|
622
|
-
"name": "init",
|
|
623
|
-
"rule": "expression",
|
|
624
|
-
},
|
|
625
|
-
)
|
|
626
|
-
self.assertEqual(rep[1], "dont need err")
|
|
627
|
-
self.assertEqual(rep[2], None)
|
|
628
|
-
self.assertEqual(rep[3], 2)
|
|
629
|
-
|
|
630
|
-
test_walker = sent.run_architype("sample")
|
|
631
|
-
test_walker.prime(gph)
|
|
632
|
-
resp = test_walker.run()
|
|
633
|
-
|
|
634
|
-
# exact line and error
|
|
635
|
-
self.assertEqual(
|
|
636
|
-
resp["errors"][0],
|
|
637
|
-
"basic:sample - line 23, col 29 - rule index_slice - Key test not found in object/dict.",
|
|
638
|
-
)
|
|
639
|
-
|
|
640
|
-
def test_node_edge_same_name(self):
|
|
641
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
642
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
643
|
-
sent.register_code(jtc.node_edge_same_name)
|
|
644
|
-
test_walker = sent.run_architype("init")
|
|
645
|
-
test_walker.prime(gph)
|
|
646
|
-
test_walker.run()
|
|
647
|
-
rep = test_walker.report
|
|
648
|
-
self.assertEqual(rep[0], {"meeting_place": "college"})
|
|
649
|
-
self.assertEqual(
|
|
650
|
-
rep[1], {"age": 32, "birthday": None, "name": "Josh", "profession": None}
|
|
651
|
-
)
|
|
652
|
-
|
|
653
|
-
def test_testcases(self):
|
|
654
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
655
|
-
sent.register_code(jtc.testcases)
|
|
656
|
-
sent.run_tests(silent=True)
|
|
657
|
-
self.assertEqual(len(sent.testcases), 4)
|
|
658
|
-
for i in sent.testcases:
|
|
659
|
-
self.assertEqual(i["passed"], True)
|
|
660
|
-
|
|
661
|
-
def test_testcase_asserts(self):
|
|
662
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
663
|
-
sent.register_code(jtc.testcase_asserts)
|
|
664
|
-
sent.run_tests(silent=True)
|
|
665
|
-
self.assertEqual(len(sent.testcases), 3)
|
|
666
|
-
self.assertEqual(sent.testcases[0]["passed"], True)
|
|
667
|
-
self.assertEqual(sent.testcases[1]["passed"], False)
|
|
668
|
-
self.assertEqual(sent.testcases[2]["passed"], False)
|
|
669
|
-
|
|
670
|
-
def test_report_not_to_jacset(self):
|
|
671
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
672
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
673
|
-
sent.register_code(jtc.report_not_to_jacset)
|
|
674
|
-
test_walker = sent.run_architype("init")
|
|
675
|
-
test_walker.prime(gph)
|
|
676
|
-
test_walker.run()
|
|
677
|
-
rep = test_walker.report
|
|
678
|
-
self.assertIn("context", rep[0][0].keys())
|
|
679
|
-
self.assertIn("j_type", rep[0][0].keys())
|
|
680
|
-
|
|
681
|
-
def test_walker_spawn_unwrap_check(self):
|
|
682
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
683
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
684
|
-
sent.register_code(jtc.walker_spawn_unwrap_check)
|
|
685
|
-
test_walker = sent.run_architype("init")
|
|
686
|
-
test_walker.prime(gph)
|
|
687
|
-
test_walker.run()
|
|
688
|
-
rep = test_walker.report
|
|
689
|
-
self.assertTrue(rep[0].startswith("urn:uuid"))
|
|
690
|
-
|
|
691
|
-
def test_std_get_report(self):
|
|
692
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
693
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
694
|
-
sent.register_code(jtc.std_get_report)
|
|
695
|
-
test_walker = sent.run_architype("init")
|
|
696
|
-
test_walker.prime(gph)
|
|
697
|
-
test_walker.run()
|
|
698
|
-
rep = test_walker.report
|
|
699
|
-
self.assertEqual(rep, [3, 5, 6, 7, [3, 5, 6, 7], 8])
|
|
700
|
-
|
|
701
|
-
def test_func_with_array_index(self):
|
|
702
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
703
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
704
|
-
sent.register_code(jtc.func_with_array_index)
|
|
705
|
-
test_walker = sent.run_architype("init")
|
|
706
|
-
test_walker.prime(gph)
|
|
707
|
-
test_walker.run()
|
|
708
|
-
rep = test_walker.report
|
|
709
|
-
self.assertEqual(rep, [3, 5, 3])
|
|
710
|
-
|
|
711
|
-
def test_rt_error_test1(self):
|
|
712
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
713
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
714
|
-
sent.register_code(jtc.rt_error_test1)
|
|
715
|
-
test_walker = sent.run_architype("init")
|
|
716
|
-
test_walker.prime(gph)
|
|
717
|
-
test_walker.run()
|
|
718
|
-
self.assertEqual(
|
|
719
|
-
"basic:init - line 4, col 0 - rule index_slice - list index out of range",
|
|
720
|
-
test_walker.runtime_errors[0],
|
|
721
|
-
)
|
|
722
|
-
|
|
723
|
-
def test_root_type_nodes(self):
|
|
724
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
725
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
726
|
-
sent.register_code(jtc.root_type_nodes)
|
|
727
|
-
test_walker = sent.run_architype("init")
|
|
728
|
-
test_walker.prime(gph)
|
|
729
|
-
test_walker.run()
|
|
730
|
-
report = test_walker.report
|
|
731
|
-
self.assertEqual(report, ["root", "root"])
|
|
732
|
-
|
|
733
|
-
def test_invalid_key_error(self):
|
|
734
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
735
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
736
|
-
sent.register_code(jtc.invalid_key_error)
|
|
737
|
-
test_walker = sent.run_architype("init")
|
|
738
|
-
test_walker.prime(gph)
|
|
739
|
-
test_walker.run()
|
|
740
|
-
errors = test_walker.runtime_errors
|
|
741
|
-
self.assertGreater(len(errors), 0)
|
|
742
|
-
|
|
743
|
-
def test_auto_cast(self):
|
|
744
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
745
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
746
|
-
sent.register_code(jtc.auto_cast)
|
|
747
|
-
test_walker = sent.run_architype("init")
|
|
748
|
-
test_walker.prime(gph)
|
|
749
|
-
test_walker.run()
|
|
750
|
-
report = test_walker.report
|
|
751
|
-
self.assertEqual(report, [True, True])
|
|
752
|
-
|
|
753
|
-
def test_no_error_on_dict_key_assign(self):
|
|
754
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
755
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
756
|
-
sent.register_code(jtc.no_error_on_dict_key_assign)
|
|
757
|
-
test_walker = sent.run_architype("init")
|
|
758
|
-
test_walker.prime(gph)
|
|
759
|
-
test_walker.run()
|
|
760
|
-
report = test_walker.report
|
|
761
|
-
self.assertEqual(report, [{"b": 4}])
|
|
762
|
-
self.assertEqual(len(test_walker.runtime_errors), 0)
|
|
763
|
-
|
|
764
|
-
def test_report_status(self):
|
|
765
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
766
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
767
|
-
sent.register_code(jtc.report_status)
|
|
768
|
-
test_walker = sent.run_architype("init")
|
|
769
|
-
test_walker.prime(gph)
|
|
770
|
-
test_walker.run()
|
|
771
|
-
report = test_walker.report
|
|
772
|
-
self.assertEqual(report, ["hello"])
|
|
773
|
-
self.assertEqual(test_walker.report_status, 302)
|
|
774
|
-
|
|
775
|
-
def test_graph_in_graph(self):
|
|
776
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
777
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
778
|
-
sent.register_code(jtc.graph_in_graph)
|
|
779
|
-
test_walker = sent.run_architype("init")
|
|
780
|
-
test_walker.prime(gph)
|
|
781
|
-
test_walker.run()
|
|
782
|
-
report = test_walker.report
|
|
783
|
-
self.assertEqual(len(report), 3)
|
|
784
|
-
|
|
785
|
-
def test_min_max_on_list(self):
|
|
786
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
787
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
788
|
-
sent.register_code(jtc.min_max_on_list)
|
|
789
|
-
test_walker = sent.run_architype("init")
|
|
790
|
-
test_walker.prime(gph)
|
|
791
|
-
test_walker.run()
|
|
792
|
-
report = test_walker.report
|
|
793
|
-
self.assertEqual(report, [531.1, 3, 5, 1])
|
|
794
|
-
|
|
795
|
-
def test_edge_bug(self):
|
|
796
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
797
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
798
|
-
sent.register_code(jtc.edge_bug)
|
|
799
|
-
test_walker = sent.run_architype("init")
|
|
800
|
-
test_walker.prime(gph)
|
|
801
|
-
test_walker.run()
|
|
802
|
-
report = test_walker.report
|
|
803
|
-
self.assertEqual(len(report[0]), 4)
|
|
804
|
-
|
|
805
|
-
def test_rand_choice(self):
|
|
806
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
807
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
808
|
-
sent.register_code(jtc.rand_choice)
|
|
809
|
-
test_walker = sent.run_architype("init")
|
|
810
|
-
test_walker.prime(gph)
|
|
811
|
-
test_walker.run()
|
|
812
|
-
report = test_walker.report
|
|
813
|
-
self.assertIn(report[1], report[0])
|
|
814
|
-
|
|
815
|
-
def test_struct_types(self):
|
|
816
|
-
sent = Sentinel(m_id=0, h=JsOrc.hook())
|
|
817
|
-
gph = Graph(m_id=0, h=sent._h)
|
|
818
|
-
sent.register_code(jtc.struct_types)
|
|
819
|
-
test_walker = sent.run_architype("init")
|
|
820
|
-
test_walker.prime(gph)
|
|
821
|
-
test_walker.run()
|
|
822
|
-
report = test_walker.report
|
|
823
|
-
self.assertEqual(report[0], [43, 33])
|
|
824
|
-
self.assertEqual(report[1], [33, 43])
|