fix collection ordering
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
from django.urls import reverse
|
||||
import pytest
|
||||
from atlas.models import Finding, Condition
|
||||
from atlas.models import CaseCollection, Finding, Condition
|
||||
#from atlas.views import GenericExamViews
|
||||
|
||||
#@pytest.mark.django_db
|
||||
@@ -80,4 +80,49 @@ def test_create_case(db, create_case):
|
||||
|
||||
def test_create_series(db, create_series):
|
||||
series = create_series
|
||||
assert series
|
||||
assert series
|
||||
|
||||
|
||||
|
||||
def test_collection(db, create_case_collection, create_case, make_case, client):
|
||||
collection: CaseCollection = create_case_collection
|
||||
|
||||
# create some cases
|
||||
case1 = create_case
|
||||
case2 = make_case()
|
||||
case3 = make_case(title="Case 3")
|
||||
case4 = make_case(title="Case 4")
|
||||
|
||||
collection.cases.set([case1, case2, case3, case4])
|
||||
|
||||
case5 = make_case(title="Case 5")
|
||||
|
||||
assert collection.cases.all().count() == 4
|
||||
|
||||
collection.add_case(case5)
|
||||
|
||||
assert collection.cases.all().count() == 5
|
||||
|
||||
assert collection.get_case_by_index(0) == case1
|
||||
assert collection.get_case_by_index(1) == case2
|
||||
assert collection.get_case_by_index(2) == case3
|
||||
assert collection.get_case_by_index(3) == case4
|
||||
assert collection.get_case_by_index(4) == case5
|
||||
|
||||
assert collection.get_absolute_url() == reverse("atlas:collection_detail", kwargs={"pk": collection.pk})
|
||||
|
||||
assert collection.get_take_url() == reverse("atlas:collection_take_start", kwargs={"pk": collection.pk})
|
||||
|
||||
new_order = [
|
||||
case5.pk,
|
||||
case1.pk,
|
||||
case2.pk,
|
||||
case3.pk,
|
||||
case4.pk
|
||||
]
|
||||
response = client.post(reverse("atlas:exam_json_edit", kwargs={"pk":collection.pk} ), json=new_order, follow=True)
|
||||
# Check that sorting the exam works
|
||||
assert response.status_code == 200
|
||||
assert response.content == b"OK"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user