edx-proctoring 6.2.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.
Files changed (293) hide show
  1. edx_proctoring/__init__.py +6 -0
  2. edx_proctoring/admin.py +502 -0
  3. edx_proctoring/api.py +3269 -0
  4. edx_proctoring/apps.py +162 -0
  5. edx_proctoring/backends/LICENSE.txt +202 -0
  6. edx_proctoring/backends/README.txt +1 -0
  7. edx_proctoring/backends/__init__.py +20 -0
  8. edx_proctoring/backends/backend.py +162 -0
  9. edx_proctoring/backends/mock.py +105 -0
  10. edx_proctoring/backends/null.py +61 -0
  11. edx_proctoring/backends/rest.py +422 -0
  12. edx_proctoring/backends/software_secure.py +423 -0
  13. edx_proctoring/backends/tests/__init__.py +3 -0
  14. edx_proctoring/backends/tests/test_backend.py +363 -0
  15. edx_proctoring/backends/tests/test_rest.py +624 -0
  16. edx_proctoring/backends/tests/test_review_payload.py +102 -0
  17. edx_proctoring/backends/tests/test_software_secure.py +628 -0
  18. edx_proctoring/callbacks.py +66 -0
  19. edx_proctoring/constants.py +83 -0
  20. edx_proctoring/decorators.py +3 -0
  21. edx_proctoring/exceptions.py +188 -0
  22. edx_proctoring/handlers.py +229 -0
  23. edx_proctoring/instructor_dashboard_exam_urls.py +19 -0
  24. edx_proctoring/locale/ar/LC_MESSAGES/django.mo +0 -0
  25. edx_proctoring/locale/ar/LC_MESSAGES/django.po +1445 -0
  26. edx_proctoring/locale/ar/LC_MESSAGES/djangojs.mo +0 -0
  27. edx_proctoring/locale/ar/LC_MESSAGES/djangojs.po +1443 -0
  28. edx_proctoring/locale/ca/LC_MESSAGES/django.mo +0 -0
  29. edx_proctoring/locale/ca/LC_MESSAGES/django.po +1464 -0
  30. edx_proctoring/locale/ca/LC_MESSAGES/djangojs.mo +0 -0
  31. edx_proctoring/locale/ca/LC_MESSAGES/djangojs.po +1463 -0
  32. edx_proctoring/locale/config.yaml +73 -0
  33. edx_proctoring/locale/cs/LC_MESSAGES/django.mo +0 -0
  34. edx_proctoring/locale/cs/LC_MESSAGES/django.po +1632 -0
  35. edx_proctoring/locale/cs/LC_MESSAGES/djangojs.mo +0 -0
  36. edx_proctoring/locale/cs/LC_MESSAGES/djangojs.po +1634 -0
  37. edx_proctoring/locale/de_DE/LC_MESSAGES/django.mo +0 -0
  38. edx_proctoring/locale/de_DE/LC_MESSAGES/django.po +1461 -0
  39. edx_proctoring/locale/de_DE/LC_MESSAGES/djangojs.mo +0 -0
  40. edx_proctoring/locale/de_DE/LC_MESSAGES/djangojs.po +1461 -0
  41. edx_proctoring/locale/el/LC_MESSAGES/django.mo +0 -0
  42. edx_proctoring/locale/el/LC_MESSAGES/django.po +1389 -0
  43. edx_proctoring/locale/el/LC_MESSAGES/djangojs.mo +0 -0
  44. edx_proctoring/locale/el/LC_MESSAGES/djangojs.po +1387 -0
  45. edx_proctoring/locale/en/LC_MESSAGES/django.mo +0 -0
  46. edx_proctoring/locale/en/LC_MESSAGES/django.po +1476 -0
  47. edx_proctoring/locale/en/LC_MESSAGES/djangojs.mo +0 -0
  48. edx_proctoring/locale/en/LC_MESSAGES/djangojs.po +264 -0
  49. edx_proctoring/locale/eo/LC_MESSAGES/django.mo +0 -0
  50. edx_proctoring/locale/eo/LC_MESSAGES/django.po +1880 -0
  51. edx_proctoring/locale/eo/LC_MESSAGES/djangojs.mo +0 -0
  52. edx_proctoring/locale/eo/LC_MESSAGES/djangojs.po +304 -0
  53. edx_proctoring/locale/es_419/LC_MESSAGES/django.mo +0 -0
  54. edx_proctoring/locale/es_419/LC_MESSAGES/django.po +1783 -0
  55. edx_proctoring/locale/es_419/LC_MESSAGES/djangojs.mo +0 -0
  56. edx_proctoring/locale/es_419/LC_MESSAGES/djangojs.po +1785 -0
  57. edx_proctoring/locale/es_AR/LC_MESSAGES/django.mo +0 -0
  58. edx_proctoring/locale/es_AR/LC_MESSAGES/django.po +1654 -0
  59. edx_proctoring/locale/es_AR/LC_MESSAGES/djangojs.mo +0 -0
  60. edx_proctoring/locale/es_AR/LC_MESSAGES/djangojs.po +1655 -0
  61. edx_proctoring/locale/es_ES/LC_MESSAGES/django.mo +0 -0
  62. edx_proctoring/locale/es_ES/LC_MESSAGES/django.po +1655 -0
  63. edx_proctoring/locale/es_ES/LC_MESSAGES/djangojs.mo +0 -0
  64. edx_proctoring/locale/es_ES/LC_MESSAGES/djangojs.po +1652 -0
  65. edx_proctoring/locale/eu_ES/LC_MESSAGES/django.mo +0 -0
  66. edx_proctoring/locale/eu_ES/LC_MESSAGES/django.po +1378 -0
  67. edx_proctoring/locale/eu_ES/LC_MESSAGES/djangojs.mo +0 -0
  68. edx_proctoring/locale/eu_ES/LC_MESSAGES/djangojs.po +1378 -0
  69. edx_proctoring/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
  70. edx_proctoring/locale/fa_IR/LC_MESSAGES/django.po +1666 -0
  71. edx_proctoring/locale/fa_IR/LC_MESSAGES/djangojs.mo +0 -0
  72. edx_proctoring/locale/fa_IR/LC_MESSAGES/djangojs.po +1665 -0
  73. edx_proctoring/locale/fr/LC_MESSAGES/django.mo +0 -0
  74. edx_proctoring/locale/fr/LC_MESSAGES/django.po +1805 -0
  75. edx_proctoring/locale/fr/LC_MESSAGES/djangojs.mo +0 -0
  76. edx_proctoring/locale/fr/LC_MESSAGES/djangojs.po +1802 -0
  77. edx_proctoring/locale/fr_CA/LC_MESSAGES/django.mo +0 -0
  78. edx_proctoring/locale/fr_CA/LC_MESSAGES/django.po +1790 -0
  79. edx_proctoring/locale/fr_CA/LC_MESSAGES/djangojs.mo +0 -0
  80. edx_proctoring/locale/fr_CA/LC_MESSAGES/djangojs.po +1793 -0
  81. edx_proctoring/locale/he/LC_MESSAGES/django.mo +0 -0
  82. edx_proctoring/locale/he/LC_MESSAGES/django.po +1444 -0
  83. edx_proctoring/locale/he/LC_MESSAGES/djangojs.mo +0 -0
  84. edx_proctoring/locale/he/LC_MESSAGES/djangojs.po +1443 -0
  85. edx_proctoring/locale/id/LC_MESSAGES/django.mo +0 -0
  86. edx_proctoring/locale/id/LC_MESSAGES/django.po +1390 -0
  87. edx_proctoring/locale/id/LC_MESSAGES/djangojs.mo +0 -0
  88. edx_proctoring/locale/id/LC_MESSAGES/djangojs.po +1389 -0
  89. edx_proctoring/locale/it_IT/LC_MESSAGES/django.mo +0 -0
  90. edx_proctoring/locale/it_IT/LC_MESSAGES/django.po +1715 -0
  91. edx_proctoring/locale/it_IT/LC_MESSAGES/djangojs.mo +0 -0
  92. edx_proctoring/locale/it_IT/LC_MESSAGES/djangojs.po +1715 -0
  93. edx_proctoring/locale/ja_JP/LC_MESSAGES/djangojs.mo +0 -0
  94. edx_proctoring/locale/ja_JP/LC_MESSAGES/djangojs.po +1387 -0
  95. edx_proctoring/locale/ka/LC_MESSAGES/django.mo +0 -0
  96. edx_proctoring/locale/ka/LC_MESSAGES/django.po +1380 -0
  97. edx_proctoring/locale/ka/LC_MESSAGES/djangojs.mo +0 -0
  98. edx_proctoring/locale/ka/LC_MESSAGES/djangojs.po +1380 -0
  99. edx_proctoring/locale/lv/LC_MESSAGES/django.mo +0 -0
  100. edx_proctoring/locale/lv/LC_MESSAGES/django.po +1377 -0
  101. edx_proctoring/locale/lv/LC_MESSAGES/djangojs.mo +0 -0
  102. edx_proctoring/locale/lv/LC_MESSAGES/djangojs.po +1377 -0
  103. edx_proctoring/locale/mn/LC_MESSAGES/django.mo +0 -0
  104. edx_proctoring/locale/mn/LC_MESSAGES/django.po +1434 -0
  105. edx_proctoring/locale/mn/LC_MESSAGES/djangojs.mo +0 -0
  106. edx_proctoring/locale/mn/LC_MESSAGES/djangojs.po +1379 -0
  107. edx_proctoring/locale/nb/LC_MESSAGES/django.mo +0 -0
  108. edx_proctoring/locale/nb/LC_MESSAGES/django.po +1393 -0
  109. edx_proctoring/locale/nb/LC_MESSAGES/djangojs.mo +0 -0
  110. edx_proctoring/locale/nb/LC_MESSAGES/djangojs.po +1393 -0
  111. edx_proctoring/locale/pl/LC_MESSAGES/django.mo +0 -0
  112. edx_proctoring/locale/pl/LC_MESSAGES/django.po +1386 -0
  113. edx_proctoring/locale/pl/LC_MESSAGES/djangojs.mo +0 -0
  114. edx_proctoring/locale/pl/LC_MESSAGES/djangojs.po +1386 -0
  115. edx_proctoring/locale/pt_PT/LC_MESSAGES/django.mo +0 -0
  116. edx_proctoring/locale/pt_PT/LC_MESSAGES/django.po +1793 -0
  117. edx_proctoring/locale/pt_PT/LC_MESSAGES/djangojs.mo +0 -0
  118. edx_proctoring/locale/pt_PT/LC_MESSAGES/djangojs.po +1810 -0
  119. edx_proctoring/locale/ro/LC_MESSAGES/django.mo +0 -0
  120. edx_proctoring/locale/ro/LC_MESSAGES/django.po +1382 -0
  121. edx_proctoring/locale/ro/LC_MESSAGES/djangojs.mo +0 -0
  122. edx_proctoring/locale/ro/LC_MESSAGES/djangojs.po +1382 -0
  123. edx_proctoring/locale/ru/LC_MESSAGES/django.mo +0 -0
  124. edx_proctoring/locale/ru/LC_MESSAGES/django.po +1456 -0
  125. edx_proctoring/locale/ru/LC_MESSAGES/djangojs.mo +0 -0
  126. edx_proctoring/locale/ru/LC_MESSAGES/djangojs.po +1459 -0
  127. edx_proctoring/locale/sw_KE/LC_MESSAGES/django.mo +0 -0
  128. edx_proctoring/locale/sw_KE/LC_MESSAGES/django.po +1462 -0
  129. edx_proctoring/locale/sw_KE/LC_MESSAGES/djangojs.mo +0 -0
  130. edx_proctoring/locale/sw_KE/LC_MESSAGES/djangojs.po +1464 -0
  131. edx_proctoring/locale/tr_TR/LC_MESSAGES/django.mo +0 -0
  132. edx_proctoring/locale/tr_TR/LC_MESSAGES/django.po +1527 -0
  133. edx_proctoring/locale/tr_TR/LC_MESSAGES/djangojs.mo +0 -0
  134. edx_proctoring/locale/tr_TR/LC_MESSAGES/djangojs.po +1527 -0
  135. edx_proctoring/locale/uk/LC_MESSAGES/django.mo +0 -0
  136. edx_proctoring/locale/uk/LC_MESSAGES/django.po +1443 -0
  137. edx_proctoring/locale/uk/LC_MESSAGES/djangojs.mo +0 -0
  138. edx_proctoring/locale/uk/LC_MESSAGES/djangojs.po +1443 -0
  139. edx_proctoring/locale/zh_CN/LC_MESSAGES/django.mo +0 -0
  140. edx_proctoring/locale/zh_CN/LC_MESSAGES/django.po +1468 -0
  141. edx_proctoring/locale/zh_CN/LC_MESSAGES/djangojs.mo +0 -0
  142. edx_proctoring/locale/zh_CN/LC_MESSAGES/djangojs.po +1469 -0
  143. edx_proctoring/management/__init__.py +3 -0
  144. edx_proctoring/management/commands/__init__.py +3 -0
  145. edx_proctoring/management/commands/reset_attempts.py +87 -0
  146. edx_proctoring/management/commands/set_attempt_status.py +52 -0
  147. edx_proctoring/management/commands/set_is_attempt_active.py +104 -0
  148. edx_proctoring/management/commands/tests/__init__.py +3 -0
  149. edx_proctoring/management/commands/tests/test_reset_attempts.py +153 -0
  150. edx_proctoring/management/commands/tests/test_set_attempt_status.py +85 -0
  151. edx_proctoring/management/commands/tests/test_set_is_attempt_active.py +85 -0
  152. edx_proctoring/management/commands/tests/test_update_attempt_status_from_review.py +113 -0
  153. edx_proctoring/management/commands/tests/test_update_attempts_for_exam.py +62 -0
  154. edx_proctoring/management/commands/update_attempt_status_from_review.py +81 -0
  155. edx_proctoring/management/commands/update_attempts_for_exam.py +78 -0
  156. edx_proctoring/migrations/0001_initial.py +227 -0
  157. edx_proctoring/migrations/0002_proctoredexamstudentattempt_is_status_acknowledged.py +18 -0
  158. edx_proctoring/migrations/0003_auto_20160101_0525.py +24 -0
  159. edx_proctoring/migrations/0004_auto_20160201_0523.py +19 -0
  160. edx_proctoring/migrations/0005_proctoredexam_hide_after_due.py +19 -0
  161. edx_proctoring/migrations/0006_allowed_time_limit_mins.py +24 -0
  162. edx_proctoring/migrations/0007_proctoredexam_backend.py +20 -0
  163. edx_proctoring/migrations/0008_auto_20181116_1551.py +32 -0
  164. edx_proctoring/migrations/0009_proctoredexamreviewpolicy_remove_rules.py +23 -0
  165. edx_proctoring/migrations/0010_update_backend.py +32 -0
  166. edx_proctoring/migrations/0011_allow_multiple_attempts.py +17 -0
  167. edx_proctoring/migrations/0012_proctoredexamstudentattempt_time_remaining_seconds.py +18 -0
  168. edx_proctoring/migrations/0013_proctoredexamsoftwaresecurereview_is_active_attempt.py +23 -0
  169. edx_proctoring/migrations/0014_add_is_resumable_to_proctoredexamstudentattempt.py +23 -0
  170. edx_proctoring/migrations/0015_rm_proctoredexamstudentattempt_ips.py +29 -0
  171. edx_proctoring/migrations/0016_nullable_proctoredexamstudentattempt_name.py +23 -0
  172. edx_proctoring/migrations/0017_rm_proctoredexamstudentattempt_name.py +21 -0
  173. edx_proctoring/migrations/0018_historicalproctoredexamstudentattempt.py +53 -0
  174. edx_proctoring/migrations/0019_proctoredexamsoftwaresecurereview_encrypted_video_url.py +18 -0
  175. edx_proctoring/migrations/0020_auto_20211028_1915.py +23 -0
  176. edx_proctoring/migrations/0021_auto_20211029_1353.py +26 -0
  177. edx_proctoring/migrations/0022_proctoredexamstudentattempt_add_readytoresume_resumed.py +33 -0
  178. edx_proctoring/migrations/0023_historicalproctoredexam.py +50 -0
  179. edx_proctoring/migrations/0024_delete_proctoredexamstudentattempthistory.py +16 -0
  180. edx_proctoring/migrations/0025_auto_20230727_2112.py +21 -0
  181. edx_proctoring/migrations/__init__.py +0 -0
  182. edx_proctoring/models.py +844 -0
  183. edx_proctoring/rules.py +15 -0
  184. edx_proctoring/runtime.py +21 -0
  185. edx_proctoring/scripts/obscure_user.py +108 -0
  186. edx_proctoring/serializers.py +147 -0
  187. edx_proctoring/services.py +43 -0
  188. edx_proctoring/settings/__init__.py +0 -0
  189. edx_proctoring/settings/common.py +50 -0
  190. edx_proctoring/settings/production.py +13 -0
  191. edx_proctoring/settings/test.py +11 -0
  192. edx_proctoring/signals.py +5 -0
  193. edx_proctoring/static/index.js +41 -0
  194. edx_proctoring/static/proctoring/clippy.swf +0 -0
  195. edx_proctoring/static/proctoring/close-modal-hover.png +0 -0
  196. edx_proctoring/static/proctoring/close-modal.png +0 -0
  197. edx_proctoring/static/proctoring/js/collections/proctored_exam_allowance_collection.js +15 -0
  198. edx_proctoring/static/proctoring/js/collections/proctored_exam_attempt_grouped_collection.js +15 -0
  199. edx_proctoring/static/proctoring/js/collections/proctored_exam_collection.js +16 -0
  200. edx_proctoring/static/proctoring/js/collections/proctored_exam_onboarding_collection.js +13 -0
  201. edx_proctoring/static/proctoring/js/dropdown.js +97 -0
  202. edx_proctoring/static/proctoring/js/exam_action_handler.js +252 -0
  203. edx_proctoring/static/proctoring/js/models/learner_onboarding_model.js +9 -0
  204. edx_proctoring/static/proctoring/js/models/proctored_exam_allowance_model.js +15 -0
  205. edx_proctoring/static/proctoring/js/models/proctored_exam_attempt_model.js +15 -0
  206. edx_proctoring/static/proctoring/js/models/proctored_exam_bulk_allowance_model.js +15 -0
  207. edx_proctoring/static/proctoring/js/models/proctored_exam_model.js +56 -0
  208. edx_proctoring/static/proctoring/js/proctored_app.js +16 -0
  209. edx_proctoring/static/proctoring/js/vendor/backbone.js +1608 -0
  210. edx_proctoring/static/proctoring/js/vendor/date.js +145 -0
  211. edx_proctoring/static/proctoring/js/vendor/i18n.js +10 -0
  212. edx_proctoring/static/proctoring/js/vendor/jquery.js +4 -0
  213. edx_proctoring/static/proctoring/js/vendor/underscore.js +1416 -0
  214. edx_proctoring/static/proctoring/js/views/Backbone.ModalDialog.js +338 -0
  215. edx_proctoring/static/proctoring/js/views/proctored_exam_add_bulk_allowance_view.js +300 -0
  216. edx_proctoring/static/proctoring/js/views/proctored_exam_allowance_view.js +204 -0
  217. edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js +307 -0
  218. edx_proctoring/static/proctoring/js/views/proctored_exam_edit_allowance_view.js +165 -0
  219. edx_proctoring/static/proctoring/js/views/proctored_exam_info.js +232 -0
  220. edx_proctoring/static/proctoring/js/views/proctored_exam_instructor_launch.js +41 -0
  221. edx_proctoring/static/proctoring/js/views/proctored_exam_onboarding_view.js +288 -0
  222. edx_proctoring/static/proctoring/js/views/proctored_exam_view.js +267 -0
  223. edx_proctoring/static/proctoring/templates/add-new-bulk-allowance.underscore +105 -0
  224. edx_proctoring/static/proctoring/templates/course_grouped_allowances.underscore +70 -0
  225. edx_proctoring/static/proctoring/templates/dashboard.underscore +3 -0
  226. edx_proctoring/static/proctoring/templates/edit-allowance.underscore +52 -0
  227. edx_proctoring/static/proctoring/templates/proctored-exam-info.underscore +46 -0
  228. edx_proctoring/static/proctoring/templates/student-onboarding-status.underscore +153 -0
  229. edx_proctoring/static/proctoring/templates/student-proctored-exam-attempts-grouped.underscore +287 -0
  230. edx_proctoring/statuses.py +330 -0
  231. edx_proctoring/templates/common/waiting_banner.html +12 -0
  232. edx_proctoring/templates/emails/proctoring_attempt_satisfactory_email.html +28 -0
  233. edx_proctoring/templates/emails/proctoring_attempt_submitted_email.html +20 -0
  234. edx_proctoring/templates/emails/proctoring_attempt_unsatisfactory_email.html +33 -0
  235. edx_proctoring/templates/onboarding_exam/entrance.html +65 -0
  236. edx_proctoring/templates/onboarding_exam/error.html +18 -0
  237. edx_proctoring/templates/onboarding_exam/ready_to_submit.html +10 -0
  238. edx_proctoring/templates/onboarding_exam/rejected.html +33 -0
  239. edx_proctoring/templates/onboarding_exam/submitted.html +60 -0
  240. edx_proctoring/templates/onboarding_exam/verified.html +23 -0
  241. edx_proctoring/templates/practice_exam/entrance.html +90 -0
  242. edx_proctoring/templates/practice_exam/error.html +42 -0
  243. edx_proctoring/templates/practice_exam/submitted.html +31 -0
  244. edx_proctoring/templates/proctored_exam/confirm-decline.html +55 -0
  245. edx_proctoring/templates/proctored_exam/entrance.html +29 -0
  246. edx_proctoring/templates/proctored_exam/error.html +26 -0
  247. edx_proctoring/templates/proctored_exam/error_modal.html +26 -0
  248. edx_proctoring/templates/proctored_exam/error_wrong_browser.html +32 -0
  249. edx_proctoring/templates/proctored_exam/expired.html +13 -0
  250. edx_proctoring/templates/proctored_exam/failed-prerequisites.html +46 -0
  251. edx_proctoring/templates/proctored_exam/footer.html +80 -0
  252. edx_proctoring/templates/proctored_exam/inactive_account.html +38 -0
  253. edx_proctoring/templates/proctored_exam/instructions.html +227 -0
  254. edx_proctoring/templates/proctored_exam/onboarding_error.html +45 -0
  255. edx_proctoring/templates/proctored_exam/pending-prerequisites.html +40 -0
  256. edx_proctoring/templates/proctored_exam/proctoring_launch_callback.html +183 -0
  257. edx_proctoring/templates/proctored_exam/proctoring_opt_out_button.html +8 -0
  258. edx_proctoring/templates/proctored_exam/ready_to_resume.html +33 -0
  259. edx_proctoring/templates/proctored_exam/ready_to_start.html +70 -0
  260. edx_proctoring/templates/proctored_exam/ready_to_submit.html +39 -0
  261. edx_proctoring/templates/proctored_exam/rejected.html +30 -0
  262. edx_proctoring/templates/proctored_exam/submitted.html +24 -0
  263. edx_proctoring/templates/proctored_exam/verified.html +19 -0
  264. edx_proctoring/templates/proctored_exam/visit_exam_content.html +38 -0
  265. edx_proctoring/templates/timed_exam/entrance.html +79 -0
  266. edx_proctoring/templates/timed_exam/expired.html +13 -0
  267. edx_proctoring/templates/timed_exam/footer.html +10 -0
  268. edx_proctoring/templates/timed_exam/ready_to_submit.html +56 -0
  269. edx_proctoring/templates/timed_exam/submitted.html +32 -0
  270. edx_proctoring/tests/__init__.py +56 -0
  271. edx_proctoring/tests/test_api.py +3878 -0
  272. edx_proctoring/tests/test_email.py +325 -0
  273. edx_proctoring/tests/test_handlers.py +56 -0
  274. edx_proctoring/tests/test_mfe_views.py +579 -0
  275. edx_proctoring/tests/test_models.py +483 -0
  276. edx_proctoring/tests/test_reviews.py +844 -0
  277. edx_proctoring/tests/test_serializer.py +34 -0
  278. edx_proctoring/tests/test_services.py +429 -0
  279. edx_proctoring/tests/test_student_view.py +1676 -0
  280. edx_proctoring/tests/test_utils/factories.py +35 -0
  281. edx_proctoring/tests/test_utils/test_utils.py +207 -0
  282. edx_proctoring/tests/test_utils/utils.py +402 -0
  283. edx_proctoring/tests/test_views.py +6501 -0
  284. edx_proctoring/tests/test_workerconfig.py +96 -0
  285. edx_proctoring/urls.py +149 -0
  286. edx_proctoring/utils.py +488 -0
  287. edx_proctoring/views.py +2333 -0
  288. edx_proctoring-6.2.0.dist-info/METADATA +152 -0
  289. edx_proctoring-6.2.0.dist-info/RECORD +293 -0
  290. edx_proctoring-6.2.0.dist-info/WHEEL +5 -0
  291. edx_proctoring-6.2.0.dist-info/entry_points.txt +11 -0
  292. edx_proctoring-6.2.0.dist-info/licenses/LICENSE.txt +674 -0
  293. edx_proctoring-6.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,624 @@
1
+ """
2
+ Tests for the REST backend
3
+ """
4
+
5
+ import json
6
+ from unittest.mock import patch
7
+
8
+ import ddt
9
+ import jwt
10
+ import responses
11
+ from requests.exceptions import HTTPError
12
+
13
+ from django.test import TestCase, override_settings
14
+ from django.utils import translation
15
+
16
+ from edx_proctoring.backends.rest import BaseRestProctoringProvider
17
+ from edx_proctoring.exceptions import (
18
+ BackendProviderCannotRegisterAttempt,
19
+ BackendProviderCannotRetireUser,
20
+ BackendProviderOnboardingException,
21
+ BackendProviderOnboardingProfilesException,
22
+ BackendProviderSentNoAttemptID
23
+ )
24
+ from edx_proctoring.statuses import ProctoredExamStudentAttemptStatus
25
+
26
+
27
+ @ddt.ddt
28
+ class RESTBackendTests(TestCase):
29
+ """
30
+ Tests for the REST backend
31
+ """
32
+ def setUp(self):
33
+ "setup tests"
34
+ BaseRestProctoringProvider.base_url = 'http://rr.fake'
35
+ self.provider = BaseRestProctoringProvider('client_id', 'client_secret')
36
+ responses.add(
37
+ responses.POST,
38
+ url=self.provider.base_url + '/oauth2/access_token',
39
+ json={'access_token': 'abcd', 'expires_in': 600},
40
+ status=200
41
+ )
42
+ self.backend_exam = {
43
+ 'course_id': 'course123',
44
+ 'id': 1,
45
+ 'external_id': 'abcdefg',
46
+ 'name': 'my exam',
47
+ 'is_active': True,
48
+ 'is_proctored': True,
49
+ 'is_practice': False,
50
+ }
51
+ self.register_exam_context = {
52
+ 'attempt_code': '2',
53
+ 'obs_user_id': 'abcdefghij',
54
+ 'full_name': 'user name',
55
+ 'lms_host': 'http://lms.com'
56
+ }
57
+
58
+ @responses.activate
59
+ def test_get_software_download_url(self):
60
+ """
61
+ Makes sure we get the expected download url
62
+ """
63
+ responses.add(
64
+ responses.GET,
65
+ url=self.provider.config_url,
66
+ json={'download_url': 'http://example.com'},
67
+ status=200,
68
+ content_type='application/json',
69
+ )
70
+ self.assertEqual(self.provider.get_software_download_url(), 'http://example.com')
71
+
72
+ @responses.activate
73
+ def test_get_proctoring_config(self):
74
+ responses.add(
75
+ responses.GET,
76
+ url=self.provider.config_url,
77
+ json={'download_url': 'http://example.com', 'config': {'allow_test': 'Allow Testing'}},
78
+ status=200,
79
+ content_type='application/json',
80
+ )
81
+ config = self.provider.get_proctoring_config()
82
+ self.assertEqual(config['config']['allow_test'], 'Allow Testing')
83
+
84
+ @responses.activate
85
+ def test_get_exam(self):
86
+ responses.add(
87
+ responses.GET,
88
+ url=self.provider.exam_url.format(exam_id=self.backend_exam['id']),
89
+ json=self.backend_exam
90
+ )
91
+ external_exam = self.provider.get_exam(self.backend_exam)
92
+ self.assertEqual(external_exam, self.backend_exam)
93
+
94
+ @responses.activate
95
+ def test_get_attempt(self):
96
+ attempt = {
97
+ 'id': 1,
98
+ 'external_id': 'abcd',
99
+ 'proctored_exam': self.backend_exam,
100
+ 'user': 1,
101
+ 'instructions': [],
102
+ }
103
+ responses.add(
104
+ responses.GET,
105
+ url=self.provider.exam_attempt_url.format(
106
+ exam_id=self.backend_exam['external_id'], attempt_id=attempt['external_id']),
107
+ json=attempt
108
+ )
109
+ external_attempt = self.provider.get_attempt(attempt)
110
+ self.assertEqual(external_attempt, attempt)
111
+ self.assertEqual(responses.calls[-1].request.headers['Accept-Language'], 'en-us')
112
+
113
+ @responses.activate
114
+ def test_get_attempt_i18n(self):
115
+ attempt = {
116
+ 'id': 1,
117
+ 'external_id': 'abcd',
118
+ 'proctored_exam': self.backend_exam,
119
+ 'user': 1,
120
+ 'instructions': []
121
+ }
122
+ responses.add(
123
+ responses.GET,
124
+ url=self.provider.exam_attempt_url.format(
125
+ exam_id=self.backend_exam['external_id'], attempt_id=attempt['external_id']),
126
+ json=attempt
127
+ )
128
+ with translation.override('es'):
129
+ external_attempt = self.provider.get_attempt(attempt)
130
+ self.assertEqual(external_attempt, attempt)
131
+ self.assertEqual(responses.calls[-1].request.headers['Accept-Language'], 'es;en-us')
132
+
133
+ @responses.activate
134
+ def test_on_exam_saved(self):
135
+ responses.add(
136
+ responses.POST,
137
+ url=self.provider.create_exam_url,
138
+ json={'id': 'abcdefg'}
139
+ )
140
+ self.backend_exam.pop('external_id')
141
+ external_id = self.provider.on_exam_saved(self.backend_exam)
142
+ self.assertEqual(external_id, 'abcdefg')
143
+
144
+ @responses.activate
145
+ def test_create_exam_with_defaults(self):
146
+ provider = BaseRestProctoringProvider(default_rules={'allow_grok': True})
147
+ responses.add(
148
+ responses.POST,
149
+ url=self.provider.create_exam_url,
150
+ json={'id': 'abcdefg'}
151
+ )
152
+ self.backend_exam.pop('external_id')
153
+ external_id = provider.on_exam_saved(self.backend_exam)
154
+ request = json.loads(responses.calls[-1].request.body.decode('utf-8'))
155
+ self.assertEqual(external_id, 'abcdefg')
156
+ self.assertTrue(request['rules']['allow_grok'])
157
+
158
+ @responses.activate
159
+ def test_update_exam(self):
160
+ responses.add(
161
+ responses.POST,
162
+ url=self.provider.exam_url.format(exam_id=self.backend_exam['external_id']),
163
+ json={'id': 'abcdefg'}
164
+ )
165
+ external_id = self.provider.on_exam_saved(self.backend_exam)
166
+ self.assertEqual(external_id, 'abcdefg')
167
+
168
+ @responses.activate
169
+ def test_failed_exam_save(self):
170
+ responses.add(
171
+ responses.POST,
172
+ url=self.provider.exam_url.format(exam_id=self.backend_exam['external_id']),
173
+ body='}{bad',
174
+ )
175
+ external_id = self.provider.on_exam_saved(self.backend_exam)
176
+ self.assertEqual(external_id, None)
177
+
178
+ @responses.activate
179
+ def test_bad_exam_save(self):
180
+ self.backend_exam['bad'] = object()
181
+ external_id = self.provider.on_exam_saved(self.backend_exam)
182
+ self.assertEqual(external_id, None)
183
+
184
+ @responses.activate
185
+ def test_register_exam_attempt(self):
186
+ responses.add(
187
+ responses.POST,
188
+ url=self.provider.create_exam_attempt_url.format(exam_id=self.backend_exam['external_id']),
189
+ json={'id': 2},
190
+ status=200
191
+ )
192
+ attempt_external_id = self.provider.register_exam_attempt(self.backend_exam, self.register_exam_context)
193
+ request = json.loads(responses.calls[-1].request.body.decode('utf-8'))
194
+ self.assertEqual(attempt_external_id, 2)
195
+ self.assertEqual(request['status'], 'created')
196
+ self.assertIn('lms_host', request)
197
+ self.assertIn('full_name', request)
198
+
199
+ @responses.activate
200
+ def test_register_exam_attempt_failure(self):
201
+ responses.add(
202
+ responses.POST,
203
+ url=self.provider.create_exam_attempt_url.format(exam_id=self.backend_exam['external_id']),
204
+ json={'error': 'something'},
205
+ status=400
206
+ )
207
+ with self.assertRaises(BackendProviderCannotRegisterAttempt):
208
+ self.provider.register_exam_attempt(self.backend_exam, self.register_exam_context)
209
+
210
+ @ddt.data(
211
+ *ProctoredExamStudentAttemptStatus.onboarding_errors
212
+ )
213
+ @responses.activate
214
+ def test_attempt_failure_onboarding(self, failure_status):
215
+ responses.add(
216
+ responses.POST,
217
+ url=self.provider.create_exam_attempt_url.format(exam_id=self.backend_exam['external_id']),
218
+ json={'status': failure_status},
219
+ status=200
220
+ )
221
+ with self.assertRaises(BackendProviderOnboardingException) as exc_manager:
222
+ self.provider.register_exam_attempt(self.backend_exam, self.register_exam_context)
223
+ exception = exc_manager.exception
224
+ assert exception.status == failure_status
225
+
226
+ @responses.activate
227
+ def test_attempt_no_id_returned(self):
228
+ responses.add(
229
+ responses.POST,
230
+ url=self.provider.create_exam_attempt_url.format(exam_id=self.backend_exam['external_id']),
231
+ json={'error': 'something'},
232
+ status=200
233
+ )
234
+ with self.assertRaises(BackendProviderSentNoAttemptID):
235
+ self.provider.register_exam_attempt(self.backend_exam, self.register_exam_context)
236
+
237
+ @ddt.data(
238
+ ['start_exam_attempt', 'start'],
239
+ ['stop_exam_attempt', 'stop'],
240
+ ['mark_erroneous_exam_attempt', 'error'],
241
+ )
242
+ @ddt.unpack
243
+ @responses.activate
244
+ def test_update_exam_attempt_status(self, provider_method_name, corresponding_status):
245
+ attempt_id = 2
246
+ responses.add(
247
+ responses.PATCH,
248
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
249
+ json={'id': 2, 'status': corresponding_status}
250
+ )
251
+ status = getattr(self.provider, provider_method_name)(self.backend_exam['external_id'], attempt_id)
252
+ self.assertEqual(status, corresponding_status)
253
+
254
+ @responses.activate
255
+ def test_malformed_json_in_response(self):
256
+ attempt_id = 2
257
+ responses.add(
258
+ responses.PATCH,
259
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
260
+ body='"]'
261
+ )
262
+ status = self.provider.mark_erroneous_exam_attempt(self.backend_exam['external_id'], attempt_id)
263
+ # the important thing is that it didn't raise an exception for bad json
264
+ self.assertEqual(status, None)
265
+
266
+ @responses.activate
267
+ def test_remove_attempt(self):
268
+ attempt_id = 2
269
+ responses.add(
270
+ responses.DELETE,
271
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
272
+ json={'status': "deleted"}
273
+ )
274
+ status = self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id)
275
+ self.assertTrue(status)
276
+
277
+ def test_remove_attempt_no_attempt(self):
278
+ status = self.provider.remove_exam_attempt(self.backend_exam['external_id'], None)
279
+ self.assertFalse(status)
280
+
281
+ def test_make_attempt_request_no_attempt(self):
282
+ """
283
+ An attempt request with no attempt id short-circuits to an empty response instead
284
+ of calling the provider, so the caller treats it as a no-op.
285
+ """
286
+ self.assertIsNone(self.provider.mark_erroneous_exam_attempt(self.backend_exam['external_id'], None))
287
+
288
+ def test_make_attempt_request_passes_timeout(self):
289
+ """
290
+ Every outbound attempt request must include an explicit timeout so that a
291
+ slow/unavailable provider cannot hang the request indefinitely.
292
+ """
293
+ attempt_id = 2
294
+ with patch.object(self.provider.session, 'request') as request_mock:
295
+ request_mock.return_value.json.return_value = {'status': 'deleted'}
296
+ self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id)
297
+ _, kwargs = request_mock.call_args
298
+ self.assertEqual(kwargs['timeout'], self.provider.timeout)
299
+
300
+ def test_remove_attempt_provider_unavailable(self):
301
+ """
302
+ A provider connection error must propagate out of the backend rather than
303
+ being swallowed, so the caller can surface a descriptive error.
304
+ """
305
+ attempt_id = 2
306
+ with patch.object(self.provider.session, 'request', side_effect=ConnectionError('boom')):
307
+ with self.assertRaises(ConnectionError):
308
+ self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id)
309
+
310
+ @responses.activate
311
+ def test_remove_attempt_not_found_is_idempotent(self):
312
+ """
313
+ A 404 from the provider means the attempt is already gone upstream, which the
314
+ backend reports as success so a retried, partially-failed reset converges.
315
+ """
316
+ attempt_id = 3
317
+ responses.add(
318
+ responses.DELETE,
319
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
320
+ status=404
321
+ )
322
+ self.assertTrue(self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id))
323
+
324
+ @responses.activate
325
+ def test_remove_attempt_http_error_raises(self):
326
+ """
327
+ A non-404 HTTP error must raise rather than be treated as an already-removed
328
+ attempt, so the caller keeps the local attempt for a later retry.
329
+ """
330
+ attempt_id = 4
331
+ responses.add(
332
+ responses.DELETE,
333
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
334
+ status=500
335
+ )
336
+ with self.assertRaises(HTTPError):
337
+ self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id)
338
+
339
+ @responses.activate
340
+ def test_remove_attempt_malformed_json_not_confirmed(self):
341
+ """
342
+ A 2xx response with an undecodable body is not a valid confirmation, so it reports
343
+ False (the API layer keeps the local attempt for strict callers).
344
+ """
345
+ attempt_id = 5
346
+ responses.add(
347
+ responses.DELETE,
348
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
349
+ body='"]'
350
+ )
351
+ self.assertFalse(self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id))
352
+
353
+ @responses.activate
354
+ def test_remove_attempt_unconfirmed_status(self):
355
+ """
356
+ A 2xx response that does not carry the documented {"status": "deleted"} payload is
357
+ not a confirmation, so it reports False rather than a successful removal.
358
+ """
359
+ attempt_id = 6
360
+ responses.add(
361
+ responses.DELETE,
362
+ url=self.provider.exam_attempt_url.format(exam_id=self.backend_exam['external_id'], attempt_id=attempt_id),
363
+ json={'status': 'pending'}
364
+ )
365
+ self.assertFalse(self.provider.remove_exam_attempt(self.backend_exam['external_id'], attempt_id))
366
+
367
+ def test_default_request_timeout(self):
368
+ """The REST backend applies a 30-second request timeout by default."""
369
+ self.assertEqual(self.provider.timeout, 30)
370
+
371
+ def test_configurable_request_timeout(self):
372
+ """A ``timeout`` in the backend configuration overrides the default and is sent on requests."""
373
+ provider = BaseRestProctoringProvider('client_id', 'client_secret', timeout=5)
374
+ self.assertEqual(provider.timeout, 5)
375
+ with patch.object(provider.session, 'request') as request_mock:
376
+ request_mock.return_value.status_code = 200
377
+ request_mock.return_value.json.return_value = {'status': 'deleted'}
378
+ provider.remove_exam_attempt(self.backend_exam['external_id'], 7)
379
+ _, kwargs = request_mock.call_args
380
+ self.assertEqual(kwargs['timeout'], 5)
381
+
382
+ def test_on_review_callback(self):
383
+ """
384
+ on_review_callback should just return the payload
385
+ """
386
+ attempt = {
387
+ 'id': 1,
388
+ 'external_id': 'abcd',
389
+ 'user': 1
390
+ }
391
+ payload = {
392
+ 'status': 'verified',
393
+ 'comments': [
394
+ {'comment': 'something happened', 'status': 'ok'}
395
+ ]
396
+ }
397
+ new_payload = self.provider.on_review_callback(attempt, payload)
398
+ self.assertEqual(payload, new_payload)
399
+
400
+ def test_get_javascript(self):
401
+ self.assertEqual(self.provider.get_javascript(), '')
402
+
403
+ @patch('edx_proctoring.backends.rest.get_files')
404
+ def test_get_javascript_bundle(self, get_files_mock):
405
+ get_files_mock.return_value = [{'name': 'rest', 'url': '/there/it/is'}]
406
+ javascript_url = self.provider.get_javascript()
407
+ self.assertEqual(javascript_url, '/there/it/is')
408
+
409
+ # test absolute URL
410
+ get_files_mock.return_value = [{'name': 'rest', 'url': 'http://www.example.com/there/it/is'}]
411
+ javascript_url = self.provider.get_javascript()
412
+ self.assertEqual(javascript_url, 'http://www.example.com/there/it/is')
413
+
414
+ @patch('edx_proctoring.backends.rest.get_files')
415
+ def test_get_javascript_empty_return(self, get_files_mock):
416
+ get_files_mock.return_value = []
417
+ javascript_url = self.provider.get_javascript()
418
+ self.assertEqual(javascript_url, '')
419
+
420
+ @patch('webpack_loader.loader.WebpackLoader.get_assets')
421
+ def test_get_javascript_swallows_errors(self, mock_get_assets):
422
+ mock_get_assets.return_value = {'status': 'done', 'chunks': {}}
423
+ javascript_url = self.provider.get_javascript()
424
+ self.assertEqual(javascript_url, '')
425
+ mock_get_assets.return_value = {'status': 'error', 'chunks': {}}
426
+ javascript_url = self.provider.get_javascript()
427
+ self.assertEqual(javascript_url, '')
428
+ mock_get_assets.return_value = {'status': 'turtle', 'chunks': {}}
429
+ javascript_url = self.provider.get_javascript()
430
+ self.assertEqual(javascript_url, '')
431
+
432
+ @patch('edx_proctoring.backends.rest.get_files')
433
+ def test_get_javascript_returns_absolute_url(self, get_files_mock):
434
+ get_files_mock.return_value = [{'name': 'rest', 'url': '/there/it/is'}]
435
+ javascript_url = self.provider.get_javascript()
436
+
437
+ # no LMS_ROOT_URL setting, so return original URL
438
+ self.assertEqual(javascript_url, '/there/it/is')
439
+
440
+ with override_settings(LMS_ROOT_URL='http://www.example.com'):
441
+ javascript_url = self.provider.get_javascript()
442
+ self.assertEqual(javascript_url, 'http://www.example.com/there/it/is')
443
+
444
+ def test_instructor_url(self):
445
+ user = {
446
+ 'id': 1,
447
+ 'full_name': 'Instructor',
448
+ 'email': 'instructor@example.com'
449
+ }
450
+ course_id = 'course+abc'
451
+ base_url = self.provider.get_instructor_url(course_id, user)
452
+ self.assertIn('?jwt=', base_url)
453
+ # now try with an exam_id and an attempt_id.
454
+ # the tokens will be different
455
+ exam_id = 'abcd'
456
+ attempt_id = 'defgh'
457
+ exam_url = self.provider.get_instructor_url(course_id, user, exam_id=exam_id)
458
+ self.assertNotEqual(exam_url, base_url)
459
+ attempt_url = self.provider.get_instructor_url(course_id, user, exam_id='abcd', attempt_id=attempt_id)
460
+ self.assertNotEqual(attempt_url, base_url)
461
+ self.assertNotEqual(attempt_url, exam_url)
462
+ # let's ensure that the last token contains all of the expected data
463
+ token = attempt_url.split('jwt=')[1]
464
+ decoded = jwt.decode(token,
465
+ issuer=self.provider.client_id,
466
+ key=self.provider.client_secret,
467
+ algorithms=['HS256'])
468
+ self.assertEqual(decoded['user'], user)
469
+ self.assertEqual(decoded['course_id'], course_id)
470
+ self.assertEqual(decoded['exam_id'], exam_id)
471
+ self.assertEqual(decoded['attempt_id'], attempt_id)
472
+
473
+ # test that correct URL is returned for a request with parameter "show_configuration_dashboard=true"
474
+ config_url = self.provider.get_instructor_url(
475
+ course_id,
476
+ user,
477
+ exam_id=exam_id,
478
+ show_configuration_dashboard=True,
479
+ )
480
+ token = config_url.split('jwt=')[1]
481
+ decoded = jwt.decode(token,
482
+ issuer=self.provider.client_id,
483
+ key=self.provider.client_secret,
484
+ algorithms=['HS256'])
485
+ self.assertTrue(decoded['config'])
486
+ self.assertEqual(decoded['exam_id'], exam_id)
487
+
488
+ @responses.activate
489
+ def test_retire_user(self):
490
+ user_id = 'abcdef5'
491
+ responses.add(
492
+ responses.DELETE,
493
+ url=self.provider.user_info_url.format(user_id=user_id),
494
+ json=True
495
+ )
496
+ result = self.provider.retire_user(user_id)
497
+ assert result is True
498
+
499
+ @responses.activate
500
+ def test_retire_unknown_user(self):
501
+ user_id = 'abcdef5'
502
+ responses.add(
503
+ responses.DELETE,
504
+ url=self.provider.user_info_url.format(user_id=user_id),
505
+ json=False
506
+ )
507
+ result = self.provider.retire_user(user_id)
508
+ assert result is False
509
+
510
+ @responses.activate
511
+ def test_retire_error(self):
512
+ user_id = 'abcdef5'
513
+ responses.add(
514
+ responses.DELETE,
515
+ url=self.provider.user_info_url.format(user_id=user_id),
516
+ body='"'
517
+ )
518
+ with self.assertRaises(BackendProviderCannotRetireUser):
519
+ self.provider.retire_user(user_id)
520
+
521
+ def test_retire_user_provider_unavailable(self):
522
+ """
523
+ If the request fails before a response is received (e.g. a timeout), retire_user
524
+ still raises BackendProviderCannotRetireUser rather than an UnboundLocalError.
525
+ """
526
+ with patch.object(self.provider.session, 'delete', side_effect=ConnectionError('boom')):
527
+ with self.assertRaises(BackendProviderCannotRetireUser):
528
+ self.provider.retire_user('abcdef6')
529
+
530
+ @responses.activate
531
+ def test_get_onboarding_profile_for_user(self):
532
+ user_id = 'abcdef5'
533
+ course_id = 'course+abc'
534
+ response_json = {'user_id': user_id, 'status': 'rejected', 'expiration_date': None}
535
+ responses.add(
536
+ responses.GET,
537
+ url=self.provider.onboarding_statuses_url.format(course_id=course_id)+'?user_id='+user_id,
538
+ json=response_json
539
+ )
540
+ result = self.provider.get_onboarding_profile_info(course_id=course_id, user_id=user_id)
541
+ assert result == response_json
542
+
543
+ @responses.activate
544
+ def test_get_onboarding_profiles_for_course_with_query_params(self):
545
+ course_id = 'course+abc'
546
+ response_json = {
547
+ "count": 3,
548
+ "next": None,
549
+ "previous": None,
550
+ "num_pages": 1,
551
+ "number": 1,
552
+ "next_page_number": None,
553
+ "prev_page_number": None,
554
+ "items_per_page": 25,
555
+ "results": [
556
+ {
557
+ "user_id": "06c3",
558
+ "status": "approved-in-course",
559
+ "expiration_date": "2021-05-21"
560
+ },
561
+ {
562
+ "user_id": "a6cf",
563
+ "status": "approved-in-course",
564
+ "expiration_date": "2022-01-22"
565
+ },
566
+ {
567
+ "user_id": "fea7",
568
+ "status": "approved-in-course",
569
+ "expiration_date": "2022-03-22"
570
+ }
571
+ ]
572
+ }
573
+ responses.add(
574
+ responses.GET,
575
+ url=self.provider.onboarding_statuses_url.format(
576
+ course_id=course_id
577
+ ) + '?status=approved-in-course&page=1&page_size=3',
578
+ json=response_json
579
+ )
580
+ result = self.provider.get_onboarding_profile_info(
581
+ course_id=course_id, status='approved-in-course', page=1, page_size=3
582
+ )
583
+ assert result == response_json
584
+
585
+ @responses.activate
586
+ def test_get_onboarding_profiles_for_course_with_no_params(self):
587
+ course_id = 'course+abc'
588
+ response_json = {
589
+ "count": 3,
590
+ "next": None,
591
+ "previous": None,
592
+ "num_pages": 1,
593
+ "number": 1,
594
+ "next_page_number": None,
595
+ "prev_page_number": None,
596
+ "items_per_page": 25,
597
+ "results": [
598
+ {
599
+ "user_id": "06c3",
600
+ "status": "approved-in-course",
601
+ "expiration_date": "2021-05-21"
602
+ }
603
+ ]
604
+ }
605
+ responses.add(
606
+ responses.GET,
607
+ url=self.provider.onboarding_statuses_url.format(course_id=course_id),
608
+ json=response_json
609
+ )
610
+ result = self.provider.get_onboarding_profile_info(course_id=course_id)
611
+ assert result == response_json
612
+
613
+ @responses.activate
614
+ def test_get_onboarding_profiles_for_unknown_user_id(self):
615
+ user_id = 'bad_user'
616
+ course_id = 'course+abc'
617
+ responses.add(
618
+ responses.GET,
619
+ url=self.provider.onboarding_statuses_url.format(course_id=course_id) + '?user_id=' + user_id,
620
+ json={'error': 'something'},
621
+ status=404
622
+ )
623
+ with self.assertRaises(BackendProviderOnboardingProfilesException):
624
+ self.provider.get_onboarding_profile_info(course_id=course_id, user_id=user_id)