35 lines
948 B
Python
35 lines
948 B
Python
import pytest
|
|
from plants.models import Species, Plant, PruningLog
|
|
from datetime import date
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_species_str():
|
|
s = Species.objects.create(common_name='Rose')
|
|
assert str(s) == 'Rose'
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_plant_str():
|
|
p = Plant.objects.create(name='Kitchen Fern', location='Kitchen')
|
|
assert str(p) == 'Kitchen Fern'
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_plant_species_nullable():
|
|
p = Plant.objects.create(name='Unknown plant', location='Hallway')
|
|
assert p.species is None
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_pruning_log_str():
|
|
p = Plant.objects.create(name='Rose', location='Garden')
|
|
log = PruningLog.objects.create(plant=p, pruned_on=date(2026, 5, 1))
|
|
assert 'Rose' in str(log)
|
|
assert '2026-05-01' in str(log)
|
|
|
|
|
|
@pytest.mark.django_db
|
|
def test_plant_pruning_months_default():
|
|
p = Plant.objects.create(name='Fern', location='Office')
|
|
assert p.pruning_months == []
|