-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Location detail view, add more tests
- Loading branch information
1 parent
354742d
commit 0ef5918
Showing
8 changed files
with
159 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import pytest | ||
|
||
from dragonroost.animals.models import Animal | ||
from dragonroost.animals.models import MedicalRecord | ||
|
||
|
||
# Animal model tests | ||
@pytest.mark.django_db | ||
def test_animal_queryset_get_available_animals(animals): | ||
qs = Animal.objects.get_available_animals() | ||
assert qs.count() > 0 | ||
assert all(animal.status == "AVAILABLE" for animal in qs) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_queryset_get_animals_needing_medical_attention(animals): | ||
qs = Animal.objects.get_animals_needing_medical_attention() | ||
assert qs.count() > 0 | ||
assert all(animal.status == "QUARANTINE" for animal in qs) | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_str_method(animal): | ||
assert str(animal) == animal.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_get_absolute_url(animal): | ||
assert animal.get_absolute_url() == f"/animals/{animal.pk}/" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_get_animal_tag(animal): | ||
assert animal.animal_tag == f"A-{animal.pk:05d}" | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_is_available(animal_is_available): | ||
assert animal_is_available.is_available is True | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_number_of_medical_records(medical_record): | ||
animal = medical_record.animal | ||
number_of_records = 1 | ||
assert animal.number_of_medical_records == number_of_records | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_animal_latest_medical_record(medical_record): | ||
animal = medical_record.animal | ||
latest_medical_record = MedicalRecord.objects.filter(animal=animal).latest( | ||
"created", | ||
) | ||
assert animal.latest_medical_record == latest_medical_record | ||
|
||
|
||
# Species model tests | ||
@pytest.mark.django_db | ||
def test_species_str_method(species): | ||
assert str(species) == species.name | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_species_get_absolute_url(species): | ||
assert species.get_absolute_url() == f"/animals/species/{species.pk}/detail/" | ||
|
||
|
||
# MedicalRecord model tests | ||
@pytest.mark.django_db | ||
def test_medical_record_str_method(medical_record): | ||
assert str(medical_record) == medical_record.notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import factory | ||
|
||
from dragonroost.people.models import Person | ||
|
||
|
||
class PersonFactory(factory.django.DjangoModelFactory): | ||
class Meta: | ||
model = Person | ||
|
||
first_name = factory.Faker("first_name") | ||
last_name = factory.Faker("last_name") | ||
email = factory.Faker("email") | ||
phone_number = "555-5555" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
{% extends "base.html" %} | ||
|
||
{% block content %} | ||
<h1>{{ location.name }} - Detail</h1> | ||
<p>{{ location.description }}</p> | ||
<a href="{% url 'business:location-update' location.id %}">Edit</a> | ||
<a href="{% url 'business:location-delete' location.id %}">Delete</a> | ||
{% endblock content %} | ||
<div class="modal modal-content"> | ||
<div class="modal-header"> | ||
<h5>Location - {{ location.name }}</h5> | ||
</div> | ||
<div class="modal-body"> | ||
<p class="card-text">Description: {{ location.description }}</p> | ||
<a href="{% url 'business:location-update' location.id %}" | ||
hx-boost="true" | ||
hx-push-url="false" | ||
hx-target="#dialog" | ||
hx-swap="innerHTML" | ||
class="btn btn-primary">Edit</a> | ||
<a href="{% url 'business:location-delete' location.id %}" | ||
hx-boost="true" | ||
hx-push-url="false" | ||
hx-target="#dialog" | ||
hx-swap="innerHTML" | ||
class="btn btn-outline-danger">Delete</a> | ||
</div> | ||
</div> |