Newer
Older
{"course_identifier": self.course.identifier,
"flow_session_id": another_fs.pk},
self.get_view_start_flow_url(self.flow_id)),
("relate-update_page_bookmark_state", [],
{"course_identifier": self.course.identifier,
"flow_session_id": another_fs.pk, "page_ordinal": 0},
self.get_view_start_flow_url(self.flow_id)),
("relate-finish_flow_session_view", [],
{"course_identifier": self.course.identifier,
"flow_session_id": another_fs.pk},
self.get_view_start_flow_url(self.flow_id)),
]:
with self.subTest(url=url):
self.tweak_session_to_lock_down()
resp = self.client.get(reverse(url, args=args, kwargs=kwargs))
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
try:
code = int(code_or_redirect)
self.assertEqual(resp.status_code, code)
except ValueError:
self.assertRedirects(
resp, code_or_redirect,
fetch_redirect_response=False)
self.assertAddMessageCallCount(1)
self.assertAddMessageCalledWith(
"Your RELATE session is currently locked down "
"to this exam flow. Navigating to other parts of "
"RELATE is not currently allowed. "
"To exit this exam, log out.")
def test_start_flow_ok(self):
for url, args, kwargs, code_or_redirect in [
("relate-view_start_flow", [],
{"course_identifier": self.course.identifier,
"flow_id": self.flow_id}, 200),
]:
with self.subTest(url=url):
self.tweak_session_to_lock_down()
resp = self.client.get(reverse(url, args=args, kwargs=kwargs))
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
try:
code = int(code_or_redirect)
self.assertEqual(resp.status_code, code)
except ValueError:
self.assertRedirects(
resp, code_or_redirect,
fetch_redirect_response=False)
self.assertAddMessageCallCount(0, reset=True)
def test_start_flow_not_ok(self):
another_flow_id = "jinja-yaml"
for url, args, kwargs, code_or_redirect in [
("relate-view_start_flow", [],
{"course_identifier": self.course.identifier,
"flow_id": another_flow_id},
self.get_view_start_flow_url(self.flow_id)),
]:
with self.subTest(url=url):
self.tweak_session_to_lock_down()
resp = self.client.get(reverse(url, args=args, kwargs=kwargs))
try:
code = int(code_or_redirect)
self.assertEqual(resp.status_code, code)
except ValueError:
self.assertRedirects(
resp, code_or_redirect,
fetch_redirect_response=False)
self.assertAddMessageCallCount(1)
self.assertAddMessageCalledWith(
"Your RELATE session is currently locked down "
"to this exam flow. Navigating to other parts of "
"RELATE is not currently allowed. "
"To exit this exam, log out.")