Erro:
Found 0 test(s). System check identified no issues (0 silenced).
Ran 0 tests in 0.000s
models.py
from django.db import models
from datetime import datetime
class Photography(models.Model):
class CategotyChoices(models.IntegerChoices):
n_a = 0, 'N/A'
nebula = 1, 'Nebula'
star = 2, 'Star'
galaxy = 3, 'Galaxy'
planet = 4, 'Planet'
name = models.CharField(max_length=100, null=False, blank=False)
subtitle = models.CharField(max_length=150, null=False, blank=False)
description = models.TextField()
category = models.PositiveSmallIntegerField(choices=CategotyChoices, default=CategotyChoices.n_a)
photo = models.ImageField(null=True, blank=True)
date = models.DateTimeField(default=datetime.now())
published = models.BooleanField(default=True)
def __str__(self):
return self.name
tests_photographys.py
from rest_framework.test import APITestCase
from rest_framework import status
from django.urls import reverse
from pathlib import Path
from apps.photography_api.models import Photography
class PhotographysTestCase(APITestCase):
def setUp(self):
self.list_url = reverse('Photographys-list')
self.photography = Photography.objects.create(
name = 'StarTest',
subtitle = 'Stars are cool!',
description = """
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
sunt in culpa qui officia deserunt mollit anim id est laborum.
""",
category = 2,
photo = Path(__file__).resolve().parent / 'media' / 'photo_test.png'
)
As pastas estão organizadas da seguinte forma
- apps
- photography_api
- test
- init.py
- tests_photographys.py
- media
- photo_test.png
- test
- photography_api