style: move PlantCardPhoto import to module level in test_models

This commit is contained in:
Stephan Kerkman 2026-05-28 21:42:49 +02:00
parent 4132406f15
commit 3b8ebd6454

View file

@ -1,5 +1,5 @@
import pytest
from plants.models import Species, Plant, PruningLog, Location
from plants.models import Species, Plant, PruningLog, Location, PlantCardPhoto
from datetime import date
@ -57,7 +57,6 @@ def test_delete_species_nulls_plant_species():
@pytest.mark.django_db
def test_card_photo_belongs_to_plant():
from plants.models import PlantCardPhoto
plant = Plant.objects.create(name='Test')
photo = PlantCardPhoto.objects.create(plant=plant, image='plants/cards/test.jpg')
assert photo.plant == plant
@ -65,7 +64,6 @@ def test_card_photo_belongs_to_plant():
@pytest.mark.django_db
def test_card_photos_ordered_by_uploaded_at():
from plants.models import PlantCardPhoto
plant = Plant.objects.create(name='Test')
p1 = PlantCardPhoto.objects.create(plant=plant, image='plants/cards/a.jpg')
p2 = PlantCardPhoto.objects.create(plant=plant, image='plants/cards/b.jpg')
@ -76,7 +74,6 @@ def test_card_photos_ordered_by_uploaded_at():
@pytest.mark.django_db
def test_card_photos_deleted_with_plant():
from plants.models import PlantCardPhoto
plant = Plant.objects.create(name='Test')
PlantCardPhoto.objects.create(plant=plant, image='plants/cards/test.jpg')
plant.delete()