style: move PlantCardPhoto import to module level in test_views

This commit is contained in:
Stephan Kerkman 2026-05-28 21:53:38 +02:00
parent 5e91983783
commit cb5dd3dc84

View file

@ -1,7 +1,7 @@
import pytest
from django.urls import reverse
from datetime import date
from plants.models import Plant, PruningLog, Location
from plants.models import Plant, PruningLog, Location, PlantCardPhoto
def make_location(name):
@ -245,7 +245,6 @@ class TestPlantCard:
class TestUploadCardPhoto:
def test_upload_creates_card_photo(self, client):
from django.core.files.uploadedfile import SimpleUploadedFile
from plants.models import PlantCardPhoto
plant = Plant.objects.create(name='Fern')
image = SimpleUploadedFile('card.jpg', b'\xff\xd8\xff\xe0' + b'\x00' * 100, content_type='image/jpeg')
resp = client.post(reverse('upload_card_photo', args=[plant.pk]), {'image': image})
@ -254,7 +253,6 @@ class TestUploadCardPhoto:
def test_upload_blocked_at_max_3(self, client):
from django.core.files.uploadedfile import SimpleUploadedFile
from plants.models import PlantCardPhoto
plant = Plant.objects.create(name='Fern')
for i in range(3):
PlantCardPhoto.objects.create(plant=plant, image=f'plants/cards/card{i}.jpg')