major update to test
This commit is contained in:
@@ -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)
|
||||
@@ -0,0 +1,35 @@
|
||||
from django.test import TestCase
|
||||
|
||||
import pytest
|
||||
from django.urls import reverse
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from generic.models import ExamCollection
|
||||
|
||||
import datetime
|
||||
|
||||
class TestExamCollections:
|
||||
def test_list_url(self, db, client):
|
||||
# Test with no content
|
||||
response = client.get(reverse("generic:examcollection_list"))
|
||||
assert response.status_code == 200
|
||||
soup = BeautifulSoup(response.content, "html.parser")
|
||||
assert "No exam collections yet" in soup.text
|
||||
|
||||
# No content yet so this should fail
|
||||
response = client.get(reverse("generic:examcollection_detail", args=( 1, )))
|
||||
assert response.status_code == 404
|
||||
|
||||
collection = ExamCollection.objects.create(name="test collection", date=datetime.date.today())
|
||||
|
||||
response = client.get(reverse("generic:examcollection_list"))
|
||||
assert response.status_code == 200
|
||||
soup = BeautifulSoup(response.content, "html.parser")
|
||||
assert collection.name in soup.find("li", class_="collection").text
|
||||
|
||||
|
||||
response = client.get(reverse("generic:examcollection_detail", args=( collection.pk, )))
|
||||
assert response.status_code == 200
|
||||
soup = BeautifulSoup(response.content, "html.parser")
|
||||
assert collection.name in soup.find("h1").text
|
||||
Reference in New Issue
Block a user