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
|
||||
Reference in New Issue
Block a user