add simple packet test
This commit is contained in:
+1
-1
@@ -715,7 +715,7 @@ class Exam(ExamBase):
|
|||||||
"cached": False,
|
"cached": False,
|
||||||
"exam_type": "long",
|
"exam_type": "long",
|
||||||
"exam_name": self.name,
|
"exam_name": self.name,
|
||||||
"exam_mode": True,
|
"exam_mode": self.exam_mode,
|
||||||
"exam_order": exam_order,
|
"exam_order": exam_order,
|
||||||
"questions": exam_questions,
|
"questions": exam_questions,
|
||||||
"based": based,
|
"based": based,
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ EXAM_VIEWS = (
|
|||||||
RapidExamViews,
|
RapidExamViews,
|
||||||
LongExamViews,
|
LongExamViews,
|
||||||
SbaExamViews,
|
SbaExamViews,
|
||||||
LongExamViews,
|
|
||||||
PhysicExamViews,
|
PhysicExamViews,
|
||||||
AnatomyExamViews,
|
AnatomyExamViews,
|
||||||
)
|
)
|
||||||
@@ -47,6 +46,11 @@ def set_up_exams(request, django_user_model, create_superuser):
|
|||||||
return request.param
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(params=EXAM_VIEWS)
|
||||||
|
def set_up_packets(request):
|
||||||
|
e = request.param.Exam.objects.create(name="test packet", exam_mode=False, active=True)
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
|
||||||
# @pytest.fixture
|
# @pytest.fixture
|
||||||
# def create_exam(db):
|
# def create_exam(db):
|
||||||
@@ -66,6 +70,28 @@ def test_index2(client, set_up_exams):
|
|||||||
== "2 exams found."
|
== "2 exams found."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_packet_json_access(db, client, set_up_packets):
|
||||||
|
"""
|
||||||
|
Simple test to check that json is retrievable from non exam mode packets
|
||||||
|
"""
|
||||||
|
if set_up_packets.app_name in JSON_APPS:
|
||||||
|
exam_id = set_up_packets.Exam.objects.get(name="test packet").pk
|
||||||
|
|
||||||
|
response = client.get(reverse(f"{set_up_packets.app_name}:exam_json", args=[exam_id]))
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
exam_json = json.loads(response.content)
|
||||||
|
|
||||||
|
# Remove the s at the end of the app name
|
||||||
|
# TODO: unify this....
|
||||||
|
#assert exam_json["eid"] == f"{set_up_packets.app_name/{exam_id}"
|
||||||
|
assert exam_json["eid"].split("/")[-1] == f"{exam_id}"
|
||||||
|
print(exam_json)
|
||||||
|
assert exam_json["exam_mode"] == False
|
||||||
|
assert exam_json["exam_name"] == "test packet"
|
||||||
|
assert len(exam_json["questions"]) == 0
|
||||||
|
|
||||||
def test_overview(client, set_up_exams):
|
def test_overview(client, set_up_exams):
|
||||||
client.login(username="admin", password="adminpassword")
|
client.login(username="admin", password="adminpassword")
|
||||||
|
|
||||||
@@ -179,6 +205,4 @@ def test_index(client, create_superuser, exam_views, django_user_model):
|
|||||||
|
|
||||||
json_response = json.loads(response.content)["exams"]
|
json_response = json.loads(response.content)["exams"]
|
||||||
|
|
||||||
print(json_response)
|
|
||||||
|
|
||||||
assert len(json_response) == 2
|
assert len(json_response) == 2
|
||||||
Reference in New Issue
Block a user