Files
vrobbler/tests/birds_tests/test_models.py
Colin Powell f160f5a7b8
Some checks failed
build & deploy / test (push) Failing after 1m19s
build & deploy / build-and-deploy (push) Has been skipped
[birds] Add much better bird importing
2026-05-15 12:10:20 -04:00

31 lines
1.0 KiB
Python

import pytest
from birds.models import Bird
class TestBirdModel:
def test_create_bird(self, db):
bird = Bird.objects.create(common_name="Blue Jay")
assert bird.common_name == "Blue Jay"
assert bird.uuid is not None
assert str(bird) == "Blue Jay"
def test_find_or_create_new(self, db):
bird = Bird.find_or_create("American Robin")
assert bird.common_name == "American Robin"
def test_find_or_create_existing(self, db, bird):
result = Bird.find_or_create("Northern Cardinal")
assert result.id == bird.id
assert result.common_name == "Northern Cardinal"
def test_find_or_create_case_insensitive(self, db, bird):
result = Bird.find_or_create("northern cardinal")
assert result.id == bird.id
def test_bird_str(self, db):
bird = Bird.objects.create(common_name="Mourning Dove")
assert str(bird) == "Mourning Dove"
def test_bird_scientific_name(self, db, bird):
assert bird.scientific_name == "Cardinalis cardinalis"