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.

Files changed (186) hide show
  1. jaseci/__init__.py +3 -37
  2. jaseci-2.0.0.dist-info/METADATA +65 -0
  3. jaseci-2.0.0.dist-info/RECORD +4 -0
  4. {jaseci-1.4.2.5.dist-info → jaseci-2.0.0.dist-info}/WHEEL +1 -2
  5. jaseci/VERSION +0 -1
  6. jaseci/cli_tools/__init__.py +0 -0
  7. jaseci/cli_tools/book_tools.py +0 -457
  8. jaseci/cli_tools/jsctl.py +0 -500
  9. jaseci/cli_tools/tests/__init__.py +0 -0
  10. jaseci/cli_tools/tests/test_jsctl.py +0 -556
  11. jaseci/extens/__init__.py +0 -0
  12. jaseci/extens/act_lib/__init__.py +0 -0
  13. jaseci/extens/act_lib/date.py +0 -117
  14. jaseci/extens/act_lib/elastic.py +0 -87
  15. jaseci/extens/act_lib/file.py +0 -76
  16. jaseci/extens/act_lib/file_handler.py +0 -189
  17. jaseci/extens/act_lib/internal.py +0 -18
  18. jaseci/extens/act_lib/jaseci.py +0 -61
  19. jaseci/extens/act_lib/mail.py +0 -10
  20. jaseci/extens/act_lib/maths.py +0 -168
  21. jaseci/extens/act_lib/net.py +0 -191
  22. jaseci/extens/act_lib/rand.py +0 -82
  23. jaseci/extens/act_lib/regex.py +0 -85
  24. jaseci/extens/act_lib/request.py +0 -169
  25. jaseci/extens/act_lib/std.py +0 -235
  26. jaseci/extens/act_lib/storage.py +0 -53
  27. jaseci/extens/act_lib/stripe.py +0 -337
  28. jaseci/extens/act_lib/task.py +0 -13
  29. jaseci/extens/act_lib/tests/__init__.py +0 -0
  30. jaseci/extens/act_lib/tests/std_test_code.py +0 -37
  31. jaseci/extens/act_lib/tests/test_date.py +0 -26
  32. jaseci/extens/act_lib/tests/test_elastic.py +0 -159
  33. jaseci/extens/act_lib/tests/test_file.py +0 -116
  34. jaseci/extens/act_lib/tests/test_file_lib.py +0 -40
  35. jaseci/extens/act_lib/tests/test_mail_lib.py +0 -33
  36. jaseci/extens/act_lib/tests/test_maths.py +0 -147
  37. jaseci/extens/act_lib/tests/test_net_lib.py +0 -62
  38. jaseci/extens/act_lib/tests/test_regex.py +0 -61
  39. jaseci/extens/act_lib/tests/test_std.py +0 -51
  40. jaseci/extens/act_lib/tests/test_std_lib.py +0 -36
  41. jaseci/extens/act_lib/tests/test_url.py +0 -32
  42. jaseci/extens/act_lib/tests/test_vector.py +0 -36
  43. jaseci/extens/act_lib/tests/test_webtool.py +0 -44
  44. jaseci/extens/act_lib/tests/test_zlib.py +0 -24
  45. jaseci/extens/act_lib/url.py +0 -79
  46. jaseci/extens/act_lib/vector.py +0 -157
  47. jaseci/extens/act_lib/webtool.py +0 -28
  48. jaseci/extens/act_lib/zip.py +0 -33
  49. jaseci/extens/api/__init__.py +0 -0
  50. jaseci/extens/api/actions_api.py +0 -170
  51. jaseci/extens/api/alias_api.py +0 -139
  52. jaseci/extens/api/architype_api.py +0 -196
  53. jaseci/extens/api/config_api.py +0 -129
  54. jaseci/extens/api/global_api.py +0 -84
  55. jaseci/extens/api/graph_api.py +0 -167
  56. jaseci/extens/api/health_api.py +0 -20
  57. jaseci/extens/api/interface.py +0 -268
  58. jaseci/extens/api/jac_api.py +0 -171
  59. jaseci/extens/api/jsorc_api.py +0 -316
  60. jaseci/extens/api/logger_api.py +0 -89
  61. jaseci/extens/api/master_api.py +0 -133
  62. jaseci/extens/api/object_api.py +0 -101
  63. jaseci/extens/api/prometheus_api.py +0 -74
  64. jaseci/extens/api/queue_api.py +0 -140
  65. jaseci/extens/api/sentinel_api.py +0 -270
  66. jaseci/extens/api/super_api.py +0 -64
  67. jaseci/extens/api/tests/__init__.py +0 -0
  68. jaseci/extens/api/tests/test_architype_api.py +0 -66
  69. jaseci/extens/api/tests/test_global_api.py +0 -179
  70. jaseci/extens/api/tests/test_graph_api.py +0 -64
  71. jaseci/extens/api/tests/test_logger_api.py +0 -43
  72. jaseci/extens/api/tests/test_object_api.py +0 -20
  73. jaseci/extens/api/tests/test_sentinel_api.py +0 -66
  74. jaseci/extens/api/tests/test_uncommon.py +0 -107
  75. jaseci/extens/api/tests/test_user_api.py +0 -32
  76. jaseci/extens/api/tests/test_walker_api.py +0 -316
  77. jaseci/extens/api/user_api.py +0 -144
  78. jaseci/extens/api/walker_api.py +0 -298
  79. jaseci/extens/api/webhook_api.py +0 -74
  80. jaseci/extens/svc/__init__.py +0 -0
  81. jaseci/extens/svc/elastic_svc.py +0 -366
  82. jaseci/extens/svc/kube_svc.py +0 -432
  83. jaseci/extens/svc/mail_svc.py +0 -156
  84. jaseci/extens/svc/prome_svc.py +0 -378
  85. jaseci/extens/svc/redis_svc.py +0 -63
  86. jaseci/extens/svc/storage_svc.py +0 -193
  87. jaseci/extens/svc/stripe_svc.py +0 -51
  88. jaseci/extens/svc/task_svc.py +0 -155
  89. jaseci/extens/svc/tasks.py +0 -302
  90. jaseci/jac/__init__.py +0 -0
  91. jaseci/jac/interpreter/__init__.py +0 -0
  92. jaseci/jac/interpreter/architype_interp.py +0 -214
  93. jaseci/jac/interpreter/interp.py +0 -1783
  94. jaseci/jac/interpreter/sentinel_interp.py +0 -257
  95. jaseci/jac/interpreter/tests/__init__.py +0 -0
  96. jaseci/jac/interpreter/tests/test_interp.py +0 -42
  97. jaseci/jac/interpreter/walker_interp.py +0 -248
  98. jaseci/jac/ir/__init__.py +0 -0
  99. jaseci/jac/ir/ast.py +0 -73
  100. jaseci/jac/ir/ast_builder.py +0 -249
  101. jaseci/jac/ir/jac_code.py +0 -152
  102. jaseci/jac/ir/passes/__init__.py +0 -6
  103. jaseci/jac/ir/passes/ast_prune_pass.py +0 -9
  104. jaseci/jac/ir/passes/codegen_pass.py +0 -244
  105. jaseci/jac/ir/passes/ir_pass.py +0 -29
  106. jaseci/jac/ir/passes/printer_pass.py +0 -23
  107. jaseci/jac/ir/passes/pt_prune_pass.py +0 -29
  108. jaseci/jac/ir/passes/schedule.py +0 -23
  109. jaseci/jac/ir/passes/stats_pass.py +0 -16
  110. jaseci/jac/jac.g4 +0 -450
  111. jaseci/jac/jac_parse/__init__.py +0 -0
  112. jaseci/jac/jac_parse/jacLexer.py +0 -809
  113. jaseci/jac/jac_parse/jacListener.py +0 -853
  114. jaseci/jac/jac_parse/jacParser.py +0 -9192
  115. jaseci/jac/jac_set.py +0 -119
  116. jaseci/jac/jsci_vm/__init__.py +0 -0
  117. jaseci/jac/jsci_vm/disasm.py +0 -94
  118. jaseci/jac/jsci_vm/inst_ptr.py +0 -31
  119. jaseci/jac/jsci_vm/machine.py +0 -188
  120. jaseci/jac/jsci_vm/op_codes.py +0 -82
  121. jaseci/jac/jsci_vm/tests/__init__.py +0 -0
  122. jaseci/jac/jsci_vm/tests/test_codegen.py +0 -31
  123. jaseci/jac/machine/__init__.py +0 -0
  124. jaseci/jac/machine/jac_scope.py +0 -85
  125. jaseci/jac/machine/jac_value.py +0 -226
  126. jaseci/jac/machine/machine_state.py +0 -383
  127. jaseci/jac/tests/__init__.py +0 -0
  128. jaseci/jac/tests/book_code.py +0 -624
  129. jaseci/jac/tests/test_book.py +0 -380
  130. jaseci/jac/tests/test_lang_14.py +0 -49
  131. jaseci/jsorc/__init__.py +0 -7
  132. jaseci/jsorc/jsorc.py +0 -642
  133. jaseci/jsorc/jsorc_settings.py +0 -211
  134. jaseci/jsorc/jsorc_utils.py +0 -298
  135. jaseci/jsorc/live_actions.py +0 -364
  136. jaseci/jsorc/manifests/__init__.py +0 -0
  137. jaseci/jsorc/manifests/database.yaml +0 -109
  138. jaseci/jsorc/manifests/elastic.yaml +0 -6024
  139. jaseci/jsorc/manifests/prometheus.yaml +0 -1383
  140. jaseci/jsorc/manifests/redis.yaml +0 -64
  141. jaseci/jsorc/memory.py +0 -258
  142. jaseci/jsorc/redis.py +0 -139
  143. jaseci/jsorc/remote_actions.py +0 -157
  144. jaseci/jsorc/tests/__init__.py +0 -0
  145. jaseci/jsorc/tests/test_actions.py +0 -542
  146. jaseci/jsorc/tests/test_jsorc.py +0 -112
  147. jaseci/prim/__init__.py +0 -0
  148. jaseci/prim/ability.py +0 -93
  149. jaseci/prim/architype.py +0 -89
  150. jaseci/prim/edge.py +0 -172
  151. jaseci/prim/element.py +0 -233
  152. jaseci/prim/graph.py +0 -26
  153. jaseci/prim/master.py +0 -64
  154. jaseci/prim/node.py +0 -532
  155. jaseci/prim/obj_mixins.py +0 -235
  156. jaseci/prim/sentinel.py +0 -281
  157. jaseci/prim/super_master.py +0 -31
  158. jaseci/prim/walker.py +0 -261
  159. jaseci/svc/__init__.py +0 -0
  160. jaseci/tests/__init__.py +0 -0
  161. jaseci/tests/infer.py +0 -39
  162. jaseci/tests/jac_test_code.py +0 -1293
  163. jaseci/tests/jac_test_progs.py +0 -774
  164. jaseci/tests/test_core.py +0 -153
  165. jaseci/tests/test_jac.py +0 -824
  166. jaseci/tests/test_node.py +0 -89
  167. jaseci/tests/test_progs.py +0 -702
  168. jaseci/tests/test_stack.py +0 -220
  169. jaseci/tests/test_stripe.py +0 -225
  170. jaseci/utils/__init__.py +0 -0
  171. jaseci/utils/actions/__init__.py +0 -0
  172. jaseci/utils/actions/actions_manager.py +0 -254
  173. jaseci/utils/actions/actions_optimizer.py +0 -516
  174. jaseci/utils/actions/actions_state.py +0 -95
  175. jaseci/utils/file_handler.py +0 -171
  176. jaseci/utils/gprof2dot.py +0 -3786
  177. jaseci/utils/id_list.py +0 -168
  178. jaseci/utils/json_handler.py +0 -70
  179. jaseci/utils/log_utils.py +0 -57
  180. jaseci/utils/test_core.py +0 -62
  181. jaseci/utils/utils.py +0 -387
  182. jaseci-1.4.2.5.dist-info/LICENSE +0 -21
  183. jaseci-1.4.2.5.dist-info/METADATA +0 -39
  184. jaseci-1.4.2.5.dist-info/RECORD +0 -184
  185. jaseci-1.4.2.5.dist-info/entry_points.txt +0 -3
  186. jaseci-1.4.2.5.dist-info/top_level.txt +0 -1
@@ -1,220 +0,0 @@
1
- from jaseci.utils.test_core import CoreTest
2
- import uuid
3
-
4
-
5
- class StackTests(CoreTest):
6
- """Unit tests for Jac Walker APIs"""
7
-
8
- fixture_src = __file__
9
-
10
- def test_walker_yield(self):
11
- self.call(
12
- self.mast,
13
- ["sentinel_register", {"code": self.load_jac("ll.jac")}],
14
- )
15
- self.call(self.mast, ["walker_run", {"name": "init"}])
16
- self.call(self.mast, ["walker_run", {"name": "gen_rand_life"}])
17
- ret = self.call(self.mast, ["walker_run", {"name": "get_gen_day"}])
18
- self.assertGreater(len(ret["report"]), 3)
19
- self.call(self.mast, ["walker_run", {"name": "get_gen_day"}])
20
- self.mast._h.commit()
21
- self.call(self.mast, ["walker_run", {"name": "get_gen_day"}])
22
- self.assertEqual(len(self.mast._h.save_obj_list), 0)
23
-
24
- def test_walker_context_auto_refresh(self):
25
- ret = self.call(
26
- self.mast,
27
- ["sentinel_register", {"code": self.load_jac("ll.jac")}],
28
- )
29
- ret = self.call(self.mast, ["walker_run", {"name": "print_life_note"}])
30
- life_node = self.mast._h.get_obj(self.mast._m_id, ret["final_node"])
31
- life_node.context.pop("note")
32
- ret = self.call(self.mast, ["walker_run", {"name": "print_life_note"}])
33
- self.assertTrue(ret["success"])
34
-
35
- def test_action_module_list(self):
36
- ret = self.call(self.smast, ["actions_module_list", {}])
37
- self.assertIn("jaseci.extens.act_lib.rand", ret)
38
- self.assertIn("jaseci.extens.act_lib.std", ret)
39
- self.assertIn("jaseci.extens.act_lib.file", ret)
40
-
41
- def test_action_module_unload_reload(self):
42
- ret = self.call(self.smast, ["actions_module_list", {}])
43
- before = len(ret)
44
- ret = self.call(
45
- self.smast,
46
- ["actions_unload_module", {"name": "jaseci.extens.act_lib.rand"}],
47
- )
48
- ret = self.call(
49
- self.smast,
50
- ["actions_unload_module", {"name": "jaseci.extens.act_lib.file"}],
51
- )
52
- ret = self.call(self.smast, ["actions_module_list", {}])
53
- self.assertEqual(len(ret), before - 2)
54
- ret = self.call(
55
- self.smast,
56
- ["actions_load_module", {"mod": "jaseci.extens.act_lib.rand"}],
57
- )
58
- ret = self.call(
59
- self.smast,
60
- ["actions_load_module", {"mod": "jaseci.extens.act_lib.file"}],
61
- )
62
- ret = self.call(self.smast, ["actions_module_list", {}])
63
- self.assertEqual(len(ret), before)
64
-
65
- def test_action_module_unload_reload_aliased(self):
66
- ret = self.call(self.smast, ["actions_module_list", {}])
67
- before = len(ret)
68
- ret = self.call(
69
- self.smast,
70
- ["actions_unload_module", {"name": "jaseci.extens.act_lib.vector"}],
71
- )
72
- ret = self.call(self.smast, ["actions_module_list", {}])
73
- self.assertEqual(len(ret), before - 1)
74
- self.assertNotIn("vector.cos_sim", self.call(self.smast, ["actions_list", {}]))
75
- ret = self.call(
76
- self.smast,
77
- ["actions_load_module", {"mod": "jaseci.extens.act_lib.vector"}],
78
- )
79
- ret = self.call(self.smast, ["actions_module_list", {}])
80
- self.assertEqual(len(ret), before)
81
-
82
- def test_action_unload(self):
83
- ret = self.call(self.smast, ["actions_module_list", {}])
84
- before = len(ret)
85
- ret = self.call(self.smast, ["actions_list", {"name": "rand"}])
86
- for i in ret:
87
- self.call(self.smast, ["actions_unload_action", {"name": i}])
88
- ret = self.call(self.smast, ["actions_module_list", {}])
89
- self.assertEqual(len(ret), before - 1)
90
- ret = self.call(
91
- self.smast,
92
- ["actions_load_module", {"mod": "jaseci.extens.act_lib.rand"}],
93
- )
94
-
95
- def test_action_set_unload(self):
96
- ret = self.call(self.smast, ["actions_module_list", {}])
97
- before = len(ret)
98
- ret = self.call(self.smast, ["actions_unload_actionset", {"name": "rand"}])
99
- ret = self.call(self.smast, ["actions_module_list", {}])
100
- self.assertEqual(len(ret), before - 1)
101
- ret = self.call(
102
- self.smast,
103
- ["actions_load_module", {"mod": "jaseci.extens.act_lib.rand"}],
104
- )
105
-
106
- def test_sentinel_missing_architype(self):
107
- """
108
- Test when the original sentinel is missing the corresponding architype for a
109
- node
110
- """
111
- ret = self.call(
112
- self.mast,
113
- ["sentinel_register", {"code": self.load_jac("simple.jac")}],
114
- )
115
- old_snt = ret[0]["jid"]
116
- ret = self.call(self.mast, ["walker_run", {"name": "init", "snt": old_snt}])
117
- node_id = ret["report"][0]["jid"]
118
- ret = self.call(self.mast, ["sentinel_delete", {"snt": old_snt}])
119
- ret = self.call(self.mast, ["sentinel_list", {"snt": old_snt}])
120
- ret = self.call(
121
- self.mast,
122
- ["graph_node_set", {"nd": node_id, "ctx": {"b": 6}}],
123
- )
124
- self.assertIn("has_var", ret["errors"][0])
125
- ret = self.call(
126
- self.mast,
127
- [
128
- "sentinel_register",
129
- {
130
- "name": "new_snt",
131
- "auto_create_graph": False,
132
- "auto_run": False,
133
- "set_active": True,
134
- "code": self.load_jac("simple.jac"),
135
- },
136
- ],
137
- )
138
- self.mast._h._machine = None
139
- ret = self.call(
140
- self.mast,
141
- ["graph_node_set", {"nd": node_id, "ctx": {"b": 6}}],
142
- )
143
- self.assertEqual(ret["context"]["b"], 6)
144
-
145
- def test_sentinel_missing_architype_global(self):
146
- """
147
- Test when the original sentinel is missing the corresponding architype for a
148
- node
149
- """
150
- ret = self.call(
151
- self.smast,
152
- [
153
- "sentinel_register",
154
- {
155
- "name": "new_snt",
156
- "auto_create_graph": False,
157
- "auto_run": False,
158
- "set_active": True,
159
- "code": self.load_jac("simple.jac"),
160
- },
161
- ],
162
- )
163
- glob_snt = ret[0]["jid"]
164
- ret = self.call(self.smast, ["global_sentinel_set", {"snt": glob_snt}])
165
- ret = self.call(
166
- self.mast,
167
- ["sentinel_register", {"code": self.load_jac("simple.jac")}],
168
- )
169
- old_snt = ret[0]["jid"]
170
- ret = self.call(self.mast, ["walker_run", {"name": "init", "snt": old_snt}])
171
- node_id = ret["report"][0]["jid"]
172
- ret = self.call(self.mast, ["sentinel_delete", {"snt": old_snt}])
173
- ret = self.call(self.mast, ["sentinel_list", {"snt": old_snt}])
174
- ret = self.call(
175
- self.mast,
176
- ["graph_node_set", {"nd": node_id, "ctx": {"b": 6}}],
177
- )
178
- self.assertIn("has_var", ret["errors"][0])
179
- ret = self.call(self.mast, ["sentinel_active_global", {}])
180
- self.mast._h._machine = None
181
- ret = self.call(
182
- self.mast,
183
- ["graph_node_set", {"nd": node_id, "ctx": {"b": 6}}],
184
- )
185
- self.assertEqual(ret["context"]["b"], 6)
186
-
187
- def test_interp_deep_except(self):
188
- ret = self.call(
189
- self.smast,
190
- [
191
- "sentinel_register",
192
- {"auto_run": "", "code": self.load_jac("simple.jac")},
193
- ],
194
- )
195
-
196
- ret = self.call(self.smast, ["walker_run", {"name": "deep_except"}])
197
- self.assertTrue(ret["success"])
198
- self.assertIn("xxxx.xxxx", ret["report"][2]["msg"])
199
-
200
- def test_dot_profiling_in_walker(self):
201
- ret = self.call(
202
- self.mast,
203
- ["sentinel_register", {"code": self.load_jac("simple.jac")}],
204
- )
205
- ret = self.call(self.mast, ["walker_run", {"name": "init", "profiling": True}])
206
- self.assertIn("digraph", ret["profile"]["graph"])
207
- self.assertIn("jaseci", ret["profile"]["graph"])
208
- self.assertGreater(len(ret["profile"]["graph"]), 1000)
209
-
210
- def test_jac_profiling_in_walker(self):
211
- ret = self.call(
212
- self.mast,
213
- ["sentinel_register", {"code": self.load_jac("simple.jac")}],
214
- )
215
- ret = self.call(
216
- self.mast, ["walker_run", {"name": "complex", "profiling": True}]
217
- )
218
- print(ret["profile"]["jac"])
219
- self.assertIn("cum_time", ret["profile"]["jac"])
220
- self.assertIn("run_walker", ret["profile"]["graph"])
@@ -1,225 +0,0 @@
1
- import stripe
2
- from unittest.mock import Mock
3
- from jaseci.utils.test_core import CoreTest, jac_testcase
4
- from jaseci.jsorc.jsorc import JsOrc
5
-
6
-
7
- class StripeTests(CoreTest):
8
- """Unit tests for Stripe actions"""
9
-
10
- fixture_src = __file__
11
-
12
- @classmethod
13
- def setUpClass(cls):
14
- config = JsOrc.settings("STRIPE_CONFIG")
15
- config["enabled"] = True
16
- config[
17
- "api_key"
18
- ] = "sk_test_51JWUIeCZO78n7fsZnPvualWhmJg1DcCI332kKnWF3q2sKGwnPADjEmNblfFWi4pWAWPuJwHxpeSoJGc0J5ButHN900Q2xBz1se"
19
- config["webhook_key"] = "test_webhook_key"
20
-
21
- JsOrc.svc_reset("stripe")
22
-
23
- super(StripeTests, cls).setUpClass()
24
- stripe.Product.create = Mock()
25
- stripe.Price.create = Mock()
26
- stripe.Product.list = Mock()
27
- stripe.Customer.create = Mock()
28
- stripe.Customer.retrieve = Mock()
29
- stripe.Customer.delete = Mock()
30
- stripe.PaymentMethod.list = Mock()
31
- stripe.PaymentMethod.attach = Mock()
32
- stripe.PaymentMethod.detach = Mock()
33
- stripe.Customer.modify = Mock()
34
- stripe.Invoice.create = Mock()
35
- stripe.Invoice.list = Mock()
36
- stripe.PaymentIntent.list = Mock()
37
- stripe.PaymentIntent.create = Mock()
38
- stripe.Subscription.list = Mock()
39
- stripe.PaymentMethod.create = Mock()
40
- stripe.Subscription.create = Mock()
41
- stripe.Subscription.delete = Mock()
42
- stripe.Subscription.retrieve = Mock()
43
- stripe.Subscription.modify = Mock()
44
- stripe.Invoice.retrieve = Mock()
45
- stripe.SubscriptionItem.create_usage_record = Mock()
46
- stripe.SubscriptionItem.list_usage_record_summaries = Mock()
47
- stripe.SubscriptionItem.retrieve = Mock()
48
- stripe.checkout.Session.create = Mock()
49
- stripe.billing_portal.Session.create = Mock()
50
-
51
- @classmethod
52
- def tearDownClass(cls):
53
- super(StripeTests, cls).tearDownClass()
54
-
55
- @jac_testcase("stripe.jac", "create_product")
56
- def test_stripe_create_product(self, ret):
57
- stripe.Product.create.assert_called_once_with(
58
- name="product1", description="new product"
59
- )
60
-
61
- @jac_testcase("stripe.jac", "create_product_price")
62
- def test_stripe_create_product_price(self, ret):
63
- stripe.Price.create.assert_called_once_with(
64
- product="product1", unit_amount=12, currency="usd", recurring={}
65
- )
66
-
67
- @jac_testcase("stripe.jac", "product_list")
68
- def test_stripe_product_list(self, ret):
69
- stripe.Product.list.assert_called_once_with(active=True)
70
-
71
- @jac_testcase("stripe.jac", "create_customer")
72
- def test_stripe_create_customer(self, ret):
73
- stripe.Customer.create.assert_called_once_with(
74
- email="test12@gmail.com",
75
- name="stripe customer",
76
- address={"billing_address": "123 metro manila"},
77
- )
78
-
79
- @jac_testcase("stripe.jac", "get_customer")
80
- def test_stripe_get_customer(self, ret):
81
- stripe.Customer.retrieve.assert_called_once_with("cus_NBsqL1C1GrrHYM")
82
-
83
- @jac_testcase("stripe.jac", "delete_customer")
84
- def test_stripe_delete_customer(self, ret):
85
- stripe.Customer.delete.assert_called_once_with("cus_NBsqL1C1GrrHYM")
86
-
87
- @jac_testcase("stripe.jac", "attach_payment_method")
88
- def test_stripe_attach_payment_method(self, ret):
89
- stripe.PaymentMethod.list.assert_called_once_with(customer="cus_NBsqL1C1GrrHYM")
90
-
91
- stripe.PaymentMethod.attach.assert_called_once_with(
92
- "pm_1MN1iN2xToAoV8chTjvX94hm", customer="cus_NBsqL1C1GrrHYM"
93
- )
94
-
95
- @jac_testcase("stripe.jac", "detach_payment_method")
96
- def test_stripe_detach_payment_method(self, ret):
97
- stripe.PaymentMethod.detach.assert_called_once_with(
98
- "pm_1MN1iN2xToAoV8chTjvX94hm"
99
- )
100
-
101
- @jac_testcase("stripe.jac", "get_payment_methods")
102
- def test_stripe_get_payment_methods(self, ret):
103
- stripe.PaymentMethod.list.assert_called_with(customer="cus_NBsqL1C1GrrHYM")
104
-
105
- @jac_testcase("stripe.jac", "update_default_payment_method")
106
- def test_stripe_update_default_payment_method(self, ret):
107
- stripe.Customer.modify.assert_called_with(
108
- "cus_NBsqL1C1GrrHYM",
109
- invoice_settings={"default_payment_method": "pm_1MN1iN2xToAoV8chTjvX94hm"},
110
- )
111
-
112
- @jac_testcase("stripe.jac", "create_invoice")
113
- def test_stripe_create_invoice(self, ret):
114
- stripe.Customer.modify.assert_called_once_with(
115
- "cus_NBsqL1C1GrrHYM",
116
- invoice_settings={"default_payment_method": "pm_1MN1iN2xToAoV8chTjvX94hm"},
117
- )
118
-
119
- @jac_testcase("stripe.jac", "get_invoice_list")
120
- def test_stripe_get_invoice_list(self, ret):
121
- stripe.Invoice.list.assert_called_once_with(
122
- customer="cus_NBsqL1C1GrrHYM",
123
- subscription="sub_1MTgMQCZO78n7fsZqu1dk6nD",
124
- )
125
-
126
- @jac_testcase("stripe.jac", "get_payment_intents")
127
- def test_stripe_get_payment_intents(self, ret):
128
- stripe.PaymentIntent.list.assert_called_once_with(customer="cus_NBsqL1C1GrrHYM")
129
-
130
- @jac_testcase("stripe.jac", "create_payment_intents")
131
- def test_stripe_create_payment_intents(self, ret):
132
- stripe.PaymentIntent.create.assert_called_once_with(
133
- amount=12,
134
- currency="usd",
135
- customer="cus_NBsqL1C1GrrHYM",
136
- payment_method_types=["card"],
137
- )
138
-
139
- @jac_testcase("stripe.jac", "get_customer_subscription")
140
- def test_stripe_get_customer_subscription(self, ret):
141
- stripe.Subscription.list.assert_called_once_with(customer="customer_id")
142
-
143
- @jac_testcase("stripe.jac", "create_payment_method")
144
- def test_stripe_create_payment_method(self, ret):
145
- stripe.PaymentMethod.create.assert_called_once_with(
146
- type="card",
147
- card={
148
- "number": "4242424242424242",
149
- "exp_month": 8,
150
- "exp_year": 2024,
151
- "cvc": "314",
152
- },
153
- billing_details={"city": "Caloocan", "country": "philippines"},
154
- )
155
-
156
- @jac_testcase("stripe.jac", "create_trial_subscription")
157
- def test_stripe_create_trial_subscription(self, ret):
158
- stripe.Subscription.create.assert_called_with(
159
- customer="cus_NBsqL1C1GrrHYM",
160
- items=[{"price": "price_1MR9T6CZO78n7fsZmNdIJplr"}],
161
- trial_period_days=14,
162
- )
163
-
164
- @jac_testcase("stripe.jac", "create_subscription")
165
- def test_stripe_create_subscription(self, ret):
166
- stripe.Subscription.create.assert_called_with(
167
- customer="cus_NBsqL1C1GrrHYM",
168
- items=[{"price": "price_1MR9T6CZO78n7fsZmNdIJplr"}],
169
- )
170
-
171
- @jac_testcase("stripe.jac", "cancel_subscription")
172
- def test_stripe_cancel_subscription(self, ret):
173
- stripe.Subscription.delete.assert_called_once_with(
174
- "sub_1MTgMQCZO78n7fsZqu1dk6nD"
175
- )
176
-
177
- @jac_testcase("stripe.jac", "get_subscription")
178
- def test_stripe_get_subscription(self, ret):
179
- stripe.Subscription.retrieve.assert_called_once_with(
180
- "sub_1MTgMQCZO78n7fsZqu1dk6nD"
181
- )
182
-
183
- @jac_testcase("stripe.jac", "update_subscription_item")
184
- def test_stripe_update_subscription_item(self, ret):
185
- stripe.Subscription.modify.assert_called_once_with(
186
- "sub_1MTgMQCZO78n7fsZqu1dk6nD",
187
- cancel_at_period_end=False,
188
- items=[
189
- {
190
- "id": "su_1MTgMQCZO78n7fsZqu1dk6nD",
191
- "price": "price_1MTgMQCZO78n7fsZqu1dk6nD",
192
- }
193
- ],
194
- )
195
-
196
- @jac_testcase("stripe.jac", "get_invoice")
197
- def test_stripe_get_invoice(self, ret):
198
- stripe.Invoice.retrieve.assert_called_once_with("inv_1MTgMQCZO78n7fsZqu1dk6nD")
199
-
200
- @jac_testcase("stripe.jac", "create_usage_report")
201
- def test_stripe_create_usage_report(self, ret):
202
- stripe.SubscriptionItem.create_usage_record.assert_called()
203
-
204
- @jac_testcase("stripe.jac", "list_usage_report")
205
- def test_stripe_list_usage_report(self, ret):
206
- stripe.SubscriptionItem.list_usage_record_summaries.assert_called()
207
-
208
- @jac_testcase("stripe.jac", "subscription_item_retrieve")
209
- def test_stripe_subscription_item_retrieve(self, ret):
210
- stripe.SubscriptionItem.retrieve.assert_called()
211
-
212
- @jac_testcase("stripe.jac", "create_checkout_session")
213
- def test_stripe_create_checkout_session(self, ret):
214
- stripe.checkout.Session.create.assert_called_once_with(
215
- success_url="https://example.com/success",
216
- mode="payment",
217
- line_items=[{"price": "price_H5ggYwtDq4fbrJ", "quantity": 12}],
218
- cancel_url="https://example.com/cancel",
219
- )
220
-
221
- @jac_testcase("stripe.jac", "create_billing_portal_session")
222
- def test_stripe_create_billing_portal_session(self, ret):
223
- stripe.billing_portal.Session.create.assert_called_once_with(
224
- customer="cus_O7ECcoZCZFwinb", return_url="https://example.com/account"
225
- )
jaseci/utils/__init__.py DELETED
File without changes
File without changes