canvas 0.33.0__py3-none-any.whl → 0.33.1__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 canvas might be problematic. Click here for more details.

Files changed (254) hide show
  1. {canvas-0.33.0.dist-info → canvas-0.33.1.dist-info}/METADATA +2 -1
  2. canvas-0.33.1.dist-info/RECORD +272 -0
  3. canvas_sdk/__init__.py +3 -0
  4. canvas_sdk/commands/__init__.py +1 -1
  5. canvas_sdk/commands/base.py +3 -0
  6. canvas_sdk/commands/commands/__init__.py +1 -0
  7. canvas_sdk/commands/commands/adjust_prescription.py +3 -0
  8. canvas_sdk/commands/commands/allergy.py +7 -0
  9. canvas_sdk/commands/commands/assess.py +2 -0
  10. canvas_sdk/commands/commands/close_goal.py +3 -0
  11. canvas_sdk/commands/commands/diagnose.py +3 -0
  12. canvas_sdk/commands/commands/exam.py +3 -0
  13. canvas_sdk/commands/commands/family_history.py +3 -0
  14. canvas_sdk/commands/commands/follow_up.py +3 -0
  15. canvas_sdk/commands/commands/goal.py +3 -0
  16. canvas_sdk/commands/commands/history_present_illness.py +3 -0
  17. canvas_sdk/commands/commands/imaging_order.py +3 -0
  18. canvas_sdk/commands/commands/instruct.py +3 -0
  19. canvas_sdk/commands/commands/lab_order.py +3 -0
  20. canvas_sdk/commands/commands/medical_history.py +3 -0
  21. canvas_sdk/commands/commands/medication_statement.py +2 -0
  22. canvas_sdk/commands/commands/past_surgical_history.py +3 -0
  23. canvas_sdk/commands/commands/perform.py +3 -0
  24. canvas_sdk/commands/commands/plan.py +3 -0
  25. canvas_sdk/commands/commands/prescribe.py +8 -0
  26. canvas_sdk/commands/commands/questionnaire/__init__.py +3 -13
  27. canvas_sdk/commands/commands/questionnaire/question.py +10 -0
  28. canvas_sdk/commands/commands/reason_for_visit.py +3 -0
  29. canvas_sdk/commands/commands/refer.py +3 -0
  30. canvas_sdk/commands/commands/refill.py +3 -0
  31. canvas_sdk/commands/commands/remove_allergy.py +3 -0
  32. canvas_sdk/commands/commands/resolve_condition.py +3 -0
  33. canvas_sdk/commands/commands/review_of_systems.py +3 -0
  34. canvas_sdk/commands/commands/stop_medication.py +3 -0
  35. canvas_sdk/commands/commands/structured_assessment.py +3 -0
  36. canvas_sdk/commands/commands/task.py +7 -0
  37. canvas_sdk/commands/commands/update_diagnosis.py +3 -0
  38. canvas_sdk/commands/commands/update_goal.py +3 -0
  39. canvas_sdk/commands/commands/vitals.py +3 -0
  40. canvas_sdk/commands/constants.py +8 -0
  41. canvas_sdk/effects/__init__.py +1 -1
  42. canvas_sdk/effects/banner_alert/__init__.py +1 -1
  43. canvas_sdk/effects/banner_alert/add_banner_alert.py +3 -0
  44. canvas_sdk/effects/banner_alert/remove_banner_alert.py +3 -0
  45. canvas_sdk/effects/base.py +7 -0
  46. canvas_sdk/effects/billing_line_item/__init__.py +5 -1
  47. canvas_sdk/effects/billing_line_item/add_billing_line_item.py +3 -0
  48. canvas_sdk/effects/billing_line_item/remove_billing_line_item.py +3 -0
  49. canvas_sdk/effects/billing_line_item/update_billing_line_item.py +3 -0
  50. canvas_sdk/effects/launch_modal.py +3 -0
  51. canvas_sdk/effects/patient_chart_summary_configuration.py +3 -0
  52. canvas_sdk/effects/patient_portal/__init__.py +1 -0
  53. canvas_sdk/effects/patient_portal/application_configuration.py +3 -0
  54. canvas_sdk/effects/patient_portal/form_result.py +3 -0
  55. canvas_sdk/effects/patient_portal_menu_configuration.py +3 -0
  56. canvas_sdk/effects/patient_profile_configuration.py +5 -1
  57. canvas_sdk/effects/protocol_card/__init__.py +1 -1
  58. canvas_sdk/effects/protocol_card/protocol_card.py +6 -0
  59. canvas_sdk/effects/questionnaire_result.py +3 -0
  60. canvas_sdk/effects/send_invite.py +3 -0
  61. canvas_sdk/effects/show_button.py +3 -0
  62. canvas_sdk/effects/simple_api.py +9 -0
  63. canvas_sdk/effects/surescripts/__init__.py +2 -2
  64. canvas_sdk/effects/surescripts/surescripts_messages.py +7 -0
  65. canvas_sdk/effects/task/__init__.py +6 -1
  66. canvas_sdk/effects/task/task.py +8 -0
  67. canvas_sdk/effects/update_user.py +3 -0
  68. canvas_sdk/effects/widgets/__init__.py +1 -1
  69. canvas_sdk/effects/widgets/portal_widget.py +3 -0
  70. canvas_sdk/events/__init__.py +6 -1
  71. canvas_sdk/events/base.py +3 -0
  72. canvas_sdk/handlers/__init__.py +1 -1
  73. canvas_sdk/handlers/action_button.py +6 -0
  74. canvas_sdk/handlers/application.py +3 -0
  75. canvas_sdk/handlers/base.py +3 -0
  76. canvas_sdk/handlers/cron_task.py +3 -0
  77. canvas_sdk/handlers/simple_api/__init__.py +3 -2
  78. canvas_sdk/handlers/simple_api/api.py +26 -1
  79. canvas_sdk/handlers/simple_api/exceptions.py +10 -0
  80. canvas_sdk/handlers/simple_api/security.py +21 -5
  81. canvas_sdk/handlers/simple_api/tools.py +9 -0
  82. canvas_sdk/protocols/__init__.py +1 -1
  83. canvas_sdk/protocols/base.py +3 -0
  84. canvas_sdk/protocols/clinical_quality_measure.py +6 -1
  85. canvas_sdk/protocols/timeframe.py +3 -0
  86. canvas_sdk/questionnaires/__init__.py +1 -1
  87. canvas_sdk/questionnaires/utils.py +7 -0
  88. canvas_sdk/templates/__init__.py +1 -1
  89. canvas_sdk/templates/utils.py +3 -0
  90. canvas_sdk/utils/__init__.py +1 -1
  91. canvas_sdk/utils/http.py +69 -35
  92. canvas_sdk/utils/plugins.py +4 -0
  93. canvas_sdk/utils/stats.py +11 -0
  94. canvas_sdk/v1/__init__.py +1 -0
  95. canvas_sdk/v1/apps.py +3 -0
  96. canvas_sdk/v1/data/__init__.py +2 -2
  97. canvas_sdk/v1/data/allergy_intolerance.py +3 -0
  98. canvas_sdk/v1/data/appointment.py +7 -0
  99. canvas_sdk/v1/data/assessment.py +3 -0
  100. canvas_sdk/v1/data/banner_alert.py +3 -0
  101. canvas_sdk/v1/data/base.py +3 -0
  102. canvas_sdk/v1/data/billing.py +7 -0
  103. canvas_sdk/v1/data/care_team.py +7 -0
  104. canvas_sdk/v1/data/command.py +3 -0
  105. canvas_sdk/v1/data/common.py +18 -0
  106. canvas_sdk/v1/data/condition.py +7 -0
  107. canvas_sdk/v1/data/coverage.py +14 -0
  108. canvas_sdk/v1/data/detected_issue.py +3 -0
  109. canvas_sdk/v1/data/device.py +3 -0
  110. canvas_sdk/v1/data/imaging.py +7 -0
  111. canvas_sdk/v1/data/lab.py +16 -0
  112. canvas_sdk/v1/data/medication.py +3 -0
  113. canvas_sdk/v1/data/note.py +9 -0
  114. canvas_sdk/v1/data/observation.py +9 -0
  115. canvas_sdk/v1/data/organization.py +3 -0
  116. canvas_sdk/v1/data/patient.py +18 -2
  117. canvas_sdk/v1/data/practicelocation.py +7 -0
  118. canvas_sdk/v1/data/protocol_override.py +7 -0
  119. canvas_sdk/v1/data/questionnaire.py +16 -3
  120. canvas_sdk/v1/data/reason_for_visit.py +3 -0
  121. canvas_sdk/v1/data/staff.py +3 -0
  122. canvas_sdk/v1/data/task.py +12 -0
  123. canvas_sdk/v1/data/team.py +8 -1
  124. canvas_sdk/v1/data/user.py +3 -0
  125. canvas_sdk/v1/models.py +2 -0
  126. canvas_sdk/value_set/__init__.py +1 -0
  127. canvas_sdk/value_set/_utilities.py +16 -0
  128. canvas_sdk/value_set/custom.py +4 -0
  129. canvas_sdk/value_set/hcc2018.py +3 -0
  130. canvas_sdk/value_set/v2022/__init__.py +1 -0
  131. canvas_sdk/value_set/v2022/adverse_event.py +3 -0
  132. canvas_sdk/value_set/v2022/allergy.py +5 -0
  133. canvas_sdk/value_set/v2022/assessment.py +5 -0
  134. canvas_sdk/value_set/v2022/communication.py +5 -0
  135. canvas_sdk/value_set/v2022/condition.py +5 -0
  136. canvas_sdk/value_set/v2022/device.py +5 -0
  137. canvas_sdk/value_set/v2022/diagnostic_study.py +5 -0
  138. canvas_sdk/value_set/v2022/encounter.py +5 -0
  139. canvas_sdk/value_set/v2022/immunization.py +5 -0
  140. canvas_sdk/value_set/v2022/individual_characteristic.py +5 -0
  141. canvas_sdk/value_set/v2022/intervention.py +5 -0
  142. canvas_sdk/value_set/v2022/laboratory_test.py +5 -0
  143. canvas_sdk/value_set/v2022/medication.py +5 -0
  144. canvas_sdk/value_set/v2022/physical_exam.py +5 -0
  145. canvas_sdk/value_set/v2022/procedure.py +5 -0
  146. canvas_sdk/value_set/v2022/symptom.py +3 -0
  147. canvas_sdk/value_set/value_set.py +9 -0
  148. canvas_sdk/views/__init__.py +1 -0
  149. logger/__init__.py +2 -0
  150. logger/logger.py +3 -0
  151. plugin_runner/aws_headers.py +1 -1
  152. plugin_runner/load_all_plugins.py +202 -0
  153. plugin_runner/plugin_runner.py +21 -24
  154. plugin_runner/sandbox.py +497 -115
  155. settings.py +5 -2
  156. canvas-0.33.0.dist-info/RECORD +0 -366
  157. canvas_cli/apps/auth/tests.py +0 -155
  158. canvas_cli/apps/plugin/tests.py +0 -85
  159. canvas_cli/conftest.py +0 -28
  160. canvas_cli/tests.py +0 -217
  161. canvas_cli/utils/context/tests.py +0 -131
  162. canvas_cli/utils/print/tests.py +0 -69
  163. canvas_cli/utils/urls/tests.py +0 -12
  164. canvas_cli/utils/validators/tests.py +0 -37
  165. canvas_sdk/commands/tests/protocol/__init__.py +0 -0
  166. canvas_sdk/commands/tests/protocol/tests.py +0 -83
  167. canvas_sdk/commands/tests/schema/__init__.py +0 -0
  168. canvas_sdk/commands/tests/schema/tests.py +0 -108
  169. canvas_sdk/commands/tests/test_base_command.py +0 -81
  170. canvas_sdk/commands/tests/test_utils.py +0 -375
  171. canvas_sdk/commands/tests/unit/__init__.py +0 -0
  172. canvas_sdk/commands/tests/unit/tests.py +0 -278
  173. canvas_sdk/effects/banner_alert/tests.py +0 -288
  174. canvas_sdk/effects/protocol_card/tests.py +0 -191
  175. canvas_sdk/questionnaires/tests/__init__.py +0 -0
  176. canvas_sdk/questionnaires/tests/test_utils.py +0 -74
  177. canvas_sdk/templates/tests/__init__.py +0 -0
  178. canvas_sdk/templates/tests/test_utils.py +0 -43
  179. canvas_sdk/tests/__init__.py +0 -0
  180. canvas_sdk/tests/handlers/__init__.py +0 -0
  181. canvas_sdk/tests/handlers/test_simple_api.py +0 -1167
  182. canvas_sdk/utils/tests.py +0 -72
  183. canvas_sdk/value_set/tests/test_value_sets.py +0 -72
  184. plugin_runner/tests/__init__.py +0 -0
  185. plugin_runner/tests/fixtures/plugins/example_plugin/CANVAS_MANIFEST.json +0 -29
  186. plugin_runner/tests/fixtures/plugins/example_plugin/README.md +0 -12
  187. plugin_runner/tests/fixtures/plugins/example_plugin/__init__.py +0 -0
  188. plugin_runner/tests/fixtures/plugins/example_plugin/protocols/__init__.py +0 -0
  189. plugin_runner/tests/fixtures/plugins/example_plugin/protocols/my_protocol.py +0 -18
  190. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/CANVAS_MANIFEST.json +0 -38
  191. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/README.md +0 -11
  192. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/__init__.py +0 -0
  193. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/protocols/my_protocol.py +0 -33
  194. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/__init__.py +0 -3
  195. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/templates/base.py +0 -6
  196. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/__init__.py +0 -5
  197. plugin_runner/tests/fixtures/plugins/test_implicit_imports_plugin/utils/base.py +0 -4
  198. plugin_runner/tests/fixtures/plugins/test_load_questionnaire/CANVAS_MANIFEST.json +0 -52
  199. plugin_runner/tests/fixtures/plugins/test_load_questionnaire/README.md +0 -11
  200. plugin_runner/tests/fixtures/plugins/test_load_questionnaire/protocols/__init__.py +0 -0
  201. plugin_runner/tests/fixtures/plugins/test_load_questionnaire/protocols/my_protocol.py +0 -39
  202. plugin_runner/tests/fixtures/plugins/test_load_questionnaire/questionnaires/example_questionnaire.yml +0 -61
  203. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/CANVAS_MANIFEST.json +0 -29
  204. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/README.md +0 -12
  205. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/__init__.py +0 -0
  206. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/other_module/base.py +0 -10
  207. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/__init__.py +0 -0
  208. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/protocols/my_protocol.py +0 -18
  209. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/CANVAS_MANIFEST.json +0 -29
  210. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/README.md +0 -12
  211. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/__init__.py +0 -0
  212. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/other_module/base.py +0 -10
  213. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/__init__.py +0 -0
  214. plugin_runner/tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/protocols/my_protocol.py +0 -18
  215. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/CANVAS_MANIFEST.json +0 -29
  216. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/README.md +0 -12
  217. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/other_module/__init__.py +0 -0
  218. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/other_module/base.py +0 -3
  219. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/protocols/__init__.py +0 -0
  220. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/protocols/my_protocol.py +0 -18
  221. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/CANVAS_MANIFEST.json +0 -29
  222. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/README.md +0 -12
  223. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/other_module/__init__.py +0 -0
  224. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/other_module/base.py +0 -6
  225. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/protocols/__init__.py +0 -0
  226. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v2/protocols/my_protocol.py +0 -18
  227. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/CANVAS_MANIFEST.json +0 -29
  228. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/README.md +0 -12
  229. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/other_module/__init__.py +0 -0
  230. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/other_module/base.py +0 -8
  231. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/protocols/__init__.py +0 -0
  232. plugin_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v3/protocols/my_protocol.py +0 -18
  233. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/CANVAS_MANIFEST.json +0 -29
  234. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/README.md +0 -12
  235. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/other_module/__init__.py +0 -0
  236. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/other_module/base.py +0 -3
  237. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/protocols/__init__.py +0 -0
  238. plugin_runner/tests/fixtures/plugins/test_module_imports_plugin/protocols/my_protocol.py +0 -18
  239. plugin_runner/tests/fixtures/plugins/test_render_template/CANVAS_MANIFEST.json +0 -47
  240. plugin_runner/tests/fixtures/plugins/test_render_template/README.md +0 -11
  241. plugin_runner/tests/fixtures/plugins/test_render_template/protocols/__init__.py +0 -0
  242. plugin_runner/tests/fixtures/plugins/test_render_template/protocols/my_protocol.py +0 -43
  243. plugin_runner/tests/fixtures/plugins/test_render_template/templates/template.html +0 -10
  244. plugin_runner/tests/fixtures/plugins/test_simple_api/CANVAS_MANIFEST.json +0 -47
  245. plugin_runner/tests/fixtures/plugins/test_simple_api/README.md +0 -11
  246. plugin_runner/tests/fixtures/plugins/test_simple_api/__init__.py +0 -0
  247. plugin_runner/tests/fixtures/plugins/test_simple_api/protocols/__init__.py +0 -0
  248. plugin_runner/tests/fixtures/plugins/test_simple_api/protocols/my_protocol.py +0 -43
  249. plugin_runner/tests/test_application.py +0 -65
  250. plugin_runner/tests/test_plugin_installer.py +0 -127
  251. plugin_runner/tests/test_plugin_runner.py +0 -388
  252. plugin_runner/tests/test_sandbox.py +0 -137
  253. {canvas-0.33.0.dist-info → canvas-0.33.1.dist-info}/WHEEL +0 -0
  254. {canvas-0.33.0.dist-info → canvas-0.33.1.dist-info}/entry_points.txt +0 -0
@@ -1,29 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_module_imports_outside_plugin_v1",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_module_imports_outside_plugin_v1.protocols.my_protocol:Protocol",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- }
17
- ],
18
- "commands": [],
19
- "content": [],
20
- "effects": [],
21
- "views": []
22
- },
23
- "secrets": [],
24
- "tags": {},
25
- "references": [],
26
- "license": "",
27
- "diagram": false,
28
- "readme": "./README.md"
29
- }
@@ -1,12 +0,0 @@
1
- ==========================
2
- test_module_imports_outside_plugin_v1
3
- ==========================
4
-
5
- ## Description
6
-
7
- A description of this plugin
8
-
9
- ### Important Note!
10
-
11
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
12
- gets updated if you add, remove, or rename protocols.
@@ -1,3 +0,0 @@
1
- def import_me() -> str:
2
- """Test method."""
3
- return "Successfully imported!"
@@ -1,18 +0,0 @@
1
- from test_module_imports_plugin.other_module.base import import_me
2
-
3
- from canvas_sdk.effects import Effect, EffectType
4
- from canvas_sdk.events import EventType
5
- from canvas_sdk.protocols import BaseProtocol
6
-
7
-
8
- class Protocol(BaseProtocol):
9
- """
10
- You should put a helpful description of this protocol's behavior here.
11
- """
12
-
13
- # Name the event type you wish to run in response to
14
- RESPONDS_TO = EventType.Name(EventType.UNKNOWN)
15
-
16
- def compute(self) -> list[Effect]:
17
- """This method gets called when an event of the type RESPONDS_TO is fired."""
18
- return [Effect(type=EffectType.LOG, payload=import_me())]
@@ -1,29 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_module_imports_outside_plugin_v2",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_module_imports_outside_plugin_v2.protocols.my_protocol:Protocol",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- }
17
- ],
18
- "commands": [],
19
- "content": [],
20
- "effects": [],
21
- "views": []
22
- },
23
- "secrets": [],
24
- "tags": {},
25
- "references": [],
26
- "license": "",
27
- "diagram": false,
28
- "readme": "./README.md"
29
- }
@@ -1,12 +0,0 @@
1
- ==========================
2
- test_module_imports_outside_plugin_v2
3
- ==========================
4
-
5
- ## Description
6
-
7
- A description of this plugin
8
-
9
- ### Important Note!
10
-
11
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
12
- gets updated if you add, remove, or rename protocols.
@@ -1,6 +0,0 @@
1
- import os
2
-
3
-
4
- def import_me() -> list[str]:
5
- """Test method."""
6
- return os.listdir(".")
@@ -1,18 +0,0 @@
1
- from test_module_imports_outside_plugin_v2.other_module.base import import_me
2
-
3
- from canvas_sdk.effects import Effect, EffectType
4
- from canvas_sdk.events import EventType
5
- from canvas_sdk.protocols import BaseProtocol
6
-
7
-
8
- class Protocol(BaseProtocol):
9
- """
10
- You should put a helpful description of this protocol's behavior here.
11
- """
12
-
13
- # Name the event type you wish to run in response to
14
- RESPONDS_TO = EventType.Name(EventType.UNKNOWN)
15
-
16
- def compute(self) -> list[Effect]:
17
- """This method gets called when an event of the type RESPONDS_TO is fired."""
18
- return [Effect(type=EffectType.LOG, payload=import_me())]
@@ -1,29 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_module_imports_outside_plugin_v3",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_module_imports_outside_plugin_v3.protocols.my_protocol:Protocol",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- }
17
- ],
18
- "commands": [],
19
- "content": [],
20
- "effects": [],
21
- "views": []
22
- },
23
- "secrets": [],
24
- "tags": {},
25
- "references": [],
26
- "license": "",
27
- "diagram": false,
28
- "readme": "./README.md"
29
- }
@@ -1,12 +0,0 @@
1
- ==========================
2
- test_module_imports_outside_plugin_v3
3
- ==========================
4
-
5
- ## Description
6
-
7
- A description of this plugin
8
-
9
- ### Important Note!
10
-
11
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
12
- gets updated if you add, remove, or rename protocols.
@@ -1,8 +0,0 @@
1
- from ...test_module_imports_outside_plugin_v2.other_module.base import (
2
- import_me as other_module_import_me,
3
- )
4
-
5
-
6
- def import_me() -> list[str]:
7
- """Test method."""
8
- return other_module_import_me()
@@ -1,18 +0,0 @@
1
- from test_module_imports_outside_plugin_v3.other_module.base import import_me
2
-
3
- from canvas_sdk.effects import Effect, EffectType
4
- from canvas_sdk.events import EventType
5
- from canvas_sdk.protocols import BaseProtocol
6
-
7
-
8
- class Protocol(BaseProtocol):
9
- """
10
- You should put a helpful description of this protocol's behavior here.
11
- """
12
-
13
- # Name the event type you wish to run in response to
14
- RESPONDS_TO = EventType.Name(EventType.UNKNOWN)
15
-
16
- def compute(self) -> list[Effect]:
17
- """This method gets called when an event of the type RESPONDS_TO is fired."""
18
- return [Effect(type=EffectType.LOG, payload=import_me())]
@@ -1,29 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_module_imports_plugin",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_module_imports_plugin.protocols.my_protocol:Protocol",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- }
17
- ],
18
- "commands": [],
19
- "content": [],
20
- "effects": [],
21
- "views": []
22
- },
23
- "secrets": [],
24
- "tags": {},
25
- "references": [],
26
- "license": "",
27
- "diagram": false,
28
- "readme": "./README.md"
29
- }
@@ -1,12 +0,0 @@
1
- ==========================
2
- test_module_imports_plugin
3
- ==========================
4
-
5
- ## Description
6
-
7
- A description of this plugin
8
-
9
- ### Important Note!
10
-
11
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
12
- gets updated if you add, remove, or rename protocols.
@@ -1,3 +0,0 @@
1
- def import_me() -> str:
2
- """Test method."""
3
- return "Successfully imported!"
@@ -1,18 +0,0 @@
1
- from test_module_imports_plugin.other_module.base import import_me
2
-
3
- from canvas_sdk.effects import Effect, EffectType
4
- from canvas_sdk.events import EventType
5
- from canvas_sdk.protocols import BaseProtocol
6
-
7
-
8
- class Protocol(BaseProtocol):
9
- """
10
- You should put a helpful description of this protocol's behavior here.
11
- """
12
-
13
- # Name the event type you wish to run in response to
14
- RESPONDS_TO = EventType.Name(EventType.UNKNOWN)
15
-
16
- def compute(self) -> list[Effect]:
17
- """This method gets called when an event of the type RESPONDS_TO is fired."""
18
- return [Effect(type=EffectType.LOG, payload=import_me())]
@@ -1,47 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_render_template",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_render_template.protocols.my_protocol:ValidTemplate",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- },
17
- {
18
- "class": "test_render_template.protocols.my_protocol:InvalidTemplate",
19
- "description": "A protocol that does xyz...",
20
- "data_access": {
21
- "event": "",
22
- "read": [],
23
- "write": []
24
- }
25
- },
26
- {
27
- "class": "test_render_template.protocols.my_protocol:ForbiddenTemplate",
28
- "description": "A protocol that does xyz...",
29
- "data_access": {
30
- "event": "",
31
- "read": [],
32
- "write": []
33
- }
34
- }
35
- ],
36
- "commands": [],
37
- "content": [],
38
- "effects": [],
39
- "views": []
40
- },
41
- "secrets": [],
42
- "tags": {},
43
- "references": [],
44
- "license": "",
45
- "diagram": false,
46
- "readme": "./README.md"
47
- }
@@ -1,11 +0,0 @@
1
- test_render_template
2
- ====================
3
-
4
- ## Description
5
-
6
- A description of this plugin
7
-
8
- ### Important Note!
9
-
10
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
11
- gets updated if you add, remove, or rename protocols.
@@ -1,43 +0,0 @@
1
- from canvas_sdk.effects import Effect, EffectType
2
- from canvas_sdk.events import EventType
3
- from canvas_sdk.protocols import BaseProtocol
4
- from canvas_sdk.templates import render_to_string
5
-
6
-
7
- class ValidTemplate(BaseProtocol):
8
- """You should put a helpful description of this protocol's behavior here."""
9
-
10
- RESPONDS_TO = [EventType.Name(EventType.UNKNOWN)]
11
-
12
- def compute(self) -> list[Effect]:
13
- """This method gets called when an event of the type RESPONDS_TO is fired."""
14
- return [
15
- Effect(type=EffectType.LOG, payload=render_to_string("templates/template.html", None))
16
- ]
17
-
18
-
19
- class InvalidTemplate(BaseProtocol):
20
- """You should put a helpful description of this protocol's behavior here."""
21
-
22
- RESPONDS_TO = [EventType.Name(EventType.UNKNOWN)]
23
-
24
- def compute(self) -> list[Effect]:
25
- """This method gets called when an event of the type RESPONDS_TO is fired."""
26
- return [
27
- Effect(type=EffectType.LOG, payload=render_to_string("templates/template1.html", None))
28
- ]
29
-
30
-
31
- class ForbiddenTemplate(BaseProtocol):
32
- """You should put a helpful description of this protocol's behavior here."""
33
-
34
- RESPONDS_TO = [EventType.Name(EventType.UNKNOWN)]
35
-
36
- def compute(self) -> list[Effect]:
37
- """This method gets called when an event of the type RESPONDS_TO is fired."""
38
- return [
39
- Effect(
40
- type=EffectType.LOG,
41
- payload=render_to_string("../../templates/template.html", None),
42
- )
43
- ]
@@ -1,10 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Title</title>
6
- </head>
7
- <body>
8
-
9
- </body>
10
- </html>
@@ -1,47 +0,0 @@
1
- {
2
- "sdk_version": "0.1.4",
3
- "plugin_version": "0.0.1",
4
- "name": "test_simple_api",
5
- "description": "Edit the description in CANVAS_MANIFEST.json",
6
- "components": {
7
- "protocols": [
8
- {
9
- "class": "test_simple_api.protocols.my_protocol:Route",
10
- "description": "A protocol that does xyz...",
11
- "data_access": {
12
- "event": "",
13
- "read": [],
14
- "write": []
15
- }
16
- },
17
- {
18
- "class": "test_simple_api.protocols.my_protocol:ErrorRoute1",
19
- "description": "A protocol that does xyz...",
20
- "data_access": {
21
- "event": "",
22
- "read": [],
23
- "write": []
24
- }
25
- },
26
- {
27
- "class": "test_simple_api.protocols.my_protocol:ErrorRoute2",
28
- "description": "A protocol that does xyz...",
29
- "data_access": {
30
- "event": "",
31
- "read": [],
32
- "write": []
33
- }
34
- }
35
- ],
36
- "commands": [],
37
- "content": [],
38
- "effects": [],
39
- "views": []
40
- },
41
- "secrets": [],
42
- "tags": {},
43
- "references": [],
44
- "license": "",
45
- "diagram": false,
46
- "readme": "./README.md"
47
- }
@@ -1,11 +0,0 @@
1
- test_simple_api
2
- ===============
3
-
4
- ## Description
5
-
6
- A description of this plugin
7
-
8
- ### Important Note!
9
-
10
- The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it
11
- gets updated if you add, remove, or rename protocols.
@@ -1,43 +0,0 @@
1
- from http import HTTPStatus
2
-
3
- from canvas_sdk.effects import Effect
4
- from canvas_sdk.effects.simple_api import Response
5
- from canvas_sdk.handlers.simple_api import Credentials, SimpleAPIRoute
6
-
7
-
8
- class NoAuth(SimpleAPIRoute):
9
- """SimpleAPIRoute base class to bypass authentication."""
10
-
11
- def authenticate(self, credentials: Credentials) -> bool:
12
- """Authenticate the request."""
13
- return True
14
-
15
-
16
- class Route(NoAuth):
17
- """Handler for /route."""
18
-
19
- PATH = "/route"
20
-
21
- def get(self) -> list[Response | Effect]:
22
- """Handler method for GET."""
23
- return [Response(status_code=HTTPStatus.OK)]
24
-
25
-
26
- class ErrorRoute1(NoAuth):
27
- """Handler #1 for /error."""
28
-
29
- PATH = "/error"
30
-
31
- def get(self) -> list[Response | Effect]:
32
- """Handler method for GET."""
33
- return [Response(status_code=HTTPStatus.OK)]
34
-
35
-
36
- class ErrorRoute2(NoAuth):
37
- """Handler #2 for /error."""
38
-
39
- PATH = "/error"
40
-
41
- def get(self) -> list[Response | Effect]:
42
- """Handler method for GET."""
43
- return [Response(status_code=HTTPStatus.OK)]
@@ -1,65 +0,0 @@
1
- import pytest
2
-
3
- from canvas_sdk.effects import Effect
4
- from canvas_sdk.effects.launch_modal import LaunchModalEffect
5
- from canvas_sdk.events import Event, EventRequest, EventType
6
- from canvas_sdk.handlers.application import Application
7
-
8
-
9
- class ExampleApplication(Application):
10
- """A concrete implementation of the Application class for testing."""
11
-
12
- def on_open(self) -> Effect:
13
- """Handle the application open event by returning a mock effect."""
14
- return LaunchModalEffect(url="https://example.com").apply()
15
-
16
-
17
- @pytest.fixture
18
- def app_instance(event: Event) -> ExampleApplication:
19
- """Provide an instance of the TestApplication with a mocked event."""
20
- app = ExampleApplication(event)
21
- return app
22
-
23
-
24
- def test_compute_event_not_targeted() -> None:
25
- """Test that compute filters out events not targeted for the app."""
26
- request = EventRequest(type=EventType.APPLICATION__ON_OPEN, target="some_identifier")
27
- event = Event(request)
28
- app = ExampleApplication(event)
29
-
30
- result = app.compute()
31
-
32
- assert result == [], "Expected no effects if the event target is not the app identifier"
33
-
34
-
35
- def test_compute_event_targeted() -> None:
36
- """Test that compute processes events targeted for the app."""
37
- request = EventRequest(
38
- type=EventType.APPLICATION__ON_OPEN,
39
- target=f"{ExampleApplication.__module__}:{ExampleApplication.__qualname__}",
40
- )
41
- event = Event(request)
42
- app = ExampleApplication(event)
43
- result = app.compute()
44
-
45
- assert len(result) == 1, "Expected a single effect if the event target is the app identifier"
46
- assert isinstance(result[0], Effect), "Effect should be an instance of Effect"
47
-
48
-
49
- def test_identifier_property() -> None:
50
- """Test the identifier property of the Application class."""
51
- expected_identifier = f"{ExampleApplication.__module__}:{ExampleApplication.__qualname__}"
52
- request = EventRequest(
53
- type=EventType.APPLICATION__ON_OPEN,
54
- target=f"{ExampleApplication.__module__}:{ExampleApplication.__qualname__}",
55
- )
56
- event = Event(request)
57
- app = ExampleApplication(event)
58
-
59
- assert app.identifier == expected_identifier, "The identifier property is incorrect"
60
-
61
-
62
- def test_abstract_method_on_open() -> None:
63
- """Test that the abstract method on_open must be implemented."""
64
- with pytest.raises(TypeError):
65
- Application(Event(EventRequest(type=EventType.UNKNOWN))) # type: ignore[abstract]