major update to test
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
@@ -0,0 +1,189 @@
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
import pytest
|
||||
from django.test import Client
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from generic.tests.conftest import create_modality, create_examination, create_plane, create_contrast, create_user
|
||||
|
||||
from atlas.models import (
|
||||
Case,
|
||||
Finding,
|
||||
Condition,
|
||||
ConditionRelationship,
|
||||
Presentation,
|
||||
Subspecialty,
|
||||
PathologicalProcess,
|
||||
Differential,
|
||||
Structure,
|
||||
Series,
|
||||
SeriesImage,
|
||||
SeriesFinding,
|
||||
CaseCollection,
|
||||
SeriesDetail,
|
||||
CaseDetail,
|
||||
BaseReportAnswer,
|
||||
CidReportAnswer,
|
||||
UserReportAnswer,
|
||||
SelfReview,
|
||||
UncategorisedDicom,
|
||||
DuplicateDicom,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_finding():
|
||||
return Finding.objects.create(name="Test Finding")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_condition():
|
||||
return Condition.objects.create(name="Test Condition")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_condition_relationship(create_condition):
|
||||
return ConditionRelationship.objects.create(
|
||||
child=create_condition, parent=create_condition
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_presentation():
|
||||
return Presentation.objects.create(name="Test Presentation")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_subspecialty():
|
||||
return Subspecialty.objects.create(name="Test Subspecialty")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_pathological_process():
|
||||
return PathologicalProcess.objects.create(name="Test Pathological Process")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_differential(create_condition, create_case):
|
||||
return Differential.objects.create(condition=create_condition, case=create_case)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_structure():
|
||||
return Structure.objects.create(name="Test Structure")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_case(
|
||||
create_subspecialty,
|
||||
create_condition,
|
||||
create_presentation,
|
||||
create_pathological_process,
|
||||
):
|
||||
subspecialty = create_subspecialty
|
||||
condition = create_condition
|
||||
presentation = create_presentation
|
||||
pathological_process = create_pathological_process
|
||||
user = get_user_model().objects.create(
|
||||
username="Test User", password="Test Password", email="testuser@example.com"
|
||||
)
|
||||
|
||||
case = Case.objects.create(
|
||||
title="Sample Case",
|
||||
description="Sample description",
|
||||
history="Sample history",
|
||||
discussion="Sample discussion",
|
||||
report="Sample report",
|
||||
diagnostic_certainty=Case.CertaintyChoices.LIKELY,
|
||||
verified=True,
|
||||
created_date=timezone.now(),
|
||||
published_date=timezone.now(),
|
||||
archive=False,
|
||||
open_access=True,
|
||||
)
|
||||
|
||||
case.subspecialty.add(subspecialty)
|
||||
case.condition.add(condition)
|
||||
case.presentation.add(presentation)
|
||||
case.pathological_process.add(pathological_process)
|
||||
case.author.add(user)
|
||||
case.editor.add(user)
|
||||
|
||||
return case
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_series(create_modality, create_examination, create_plane, create_contrast, create_user):
|
||||
author=create_user
|
||||
series_instance_uid="1234567890"
|
||||
modality = create_modality
|
||||
examination = create_examination
|
||||
plane = create_plane
|
||||
contrast = create_contrast
|
||||
|
||||
series = Series.objects.create(
|
||||
modality=modality,
|
||||
examination=examination,
|
||||
plane=plane,
|
||||
contrast=contrast,
|
||||
series_instance_uid=series_instance_uid
|
||||
)
|
||||
|
||||
series.author.add(author)
|
||||
|
||||
return series
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_series_image():
|
||||
return SeriesImage.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_series_finding():
|
||||
return SeriesFinding.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_case_collection():
|
||||
return CaseCollection.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_series_detail():
|
||||
return SeriesDetail.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_case_detail():
|
||||
return CaseDetail.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_base_report_answer():
|
||||
return BaseReportAnswer.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_cid_report_answer():
|
||||
return CidReportAnswer.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_user_report_answer():
|
||||
return UserReportAnswer.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_self_review():
|
||||
return SelfReview.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_uncategorised_dicom():
|
||||
return UncategorisedDicom.objects.create()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def create_duplicate_dicom():
|
||||
return DuplicateDicom()
|
||||
@@ -72,4 +72,12 @@ def test_condition_tree_structure(db):
|
||||
# client.login(username="basicuser", password="password")
|
||||
# response = client.get(reverse('rapids:active_exams'))
|
||||
# print(response.content)
|
||||
# assert response.status_code == 200
|
||||
# assert response.status_code == 200
|
||||
|
||||
def test_create_case(db, create_case):
|
||||
case = create_case
|
||||
assert case.title == "Sample Case"
|
||||
|
||||
def test_create_series(db, create_series):
|
||||
series = create_series
|
||||
assert series
|
||||
@@ -0,0 +1,31 @@
|
||||
from django.conf import settings
|
||||
from django.utils import timezone
|
||||
import pytest
|
||||
from django.test import Client
|
||||
|
||||
from generic.models import Modality, Plane, Contrast, Examination, Site
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
@pytest.fixture
|
||||
def create_user(db):
|
||||
return get_user_model().objects.create_user(
|
||||
username="testuser",
|
||||
password="testpassword",
|
||||
email="test@test.com"
|
||||
)
|
||||
|
||||
@pytest.fixture
|
||||
def create_modality():
|
||||
return Modality.objects.create(modality="Test Modality")
|
||||
|
||||
@pytest.fixture
|
||||
def create_plane():
|
||||
return Plane.objects.create(plane="Test Plane")
|
||||
|
||||
@pytest.fixture
|
||||
def create_contrast():
|
||||
return Contrast.objects.create(contrast="Test Contrast")
|
||||
|
||||
@pytest.fixture
|
||||
def create_examination(create_modality):
|
||||
return Examination.objects.create(examination="Test Examination", modality=create_modality)
|
||||
@@ -4,6 +4,8 @@ from django.urls import reverse
|
||||
|
||||
from longs.models import Long
|
||||
|
||||
from generic.tests.conftest import create_modality, create_examination, create_plane, create_contrast, create_user
|
||||
|
||||
@pytest.fixture
|
||||
def create_long(db):
|
||||
return Long.objects.create(
|
||||
|
||||
@@ -58,7 +58,7 @@ def create_exam(db):
|
||||
return exam
|
||||
|
||||
|
||||
def create_examination(db):
|
||||
def create_examinations(db):
|
||||
examination = Examination.objects.create(examination="test examination")
|
||||
examination.save()
|
||||
examination = Examination.objects.create(examination="test examination 2")
|
||||
@@ -68,7 +68,7 @@ def create_examination(db):
|
||||
def create_long_series(question, image_number=5):
|
||||
series = LongSeries(
|
||||
description="Test series",
|
||||
examination=Examination.objects.get(pk=1),
|
||||
examination=Examination.objects.all().first(),
|
||||
)
|
||||
|
||||
series.save()
|
||||
@@ -118,7 +118,7 @@ def test_exams(db, client):
|
||||
|
||||
# create_structures(db)
|
||||
# create_question_types(db)
|
||||
create_examination(db)
|
||||
create_examinations(db)
|
||||
|
||||
question1 = create_question(exam)
|
||||
generated_questions = [question1, create_question(exam), create_question(exam)]
|
||||
|
||||
Reference in New Issue
Block a user