lostplaces-backend/lostplaces/lostplaces_app/tests/models/test_abstract_models.py

45 lines
968 B
Python
Raw Normal View History

2020-09-13 10:27:01 +02:00
import datetime
from django.test import TestCase
from django.db import models
from django.contrib.auth.models import User
from lostplaces_app.models import Place, Taggable, MapablePoint
2020-09-13 18:37:21 +02:00
from lostplaces_app.tests.models import ModelTestCase
2020-09-13 10:27:01 +02:00
from taggit.managers import TaggableManager
2020-09-13 18:37:21 +02:00
class TaggableTestCase(ModelTestCase):
2020-09-13 10:27:01 +02:00
model = Taggable
def test_tags(self):
2020-09-13 13:29:27 +02:00
self.assertField('tags', TaggableManager)
2020-09-13 10:27:01 +02:00
2020-09-13 18:37:21 +02:00
class MapablePointTestCase(ModelTestCase):
2020-09-13 10:27:01 +02:00
model = MapablePoint
def test_name(self):
2020-09-13 13:30:11 +02:00
self.assertCharField(
2020-09-13 10:27:01 +02:00
field_name='name',
min_length=10,
max_length=100
)
def test_latitude(self):
2020-09-13 13:30:47 +02:00
self.assertFloatField(
2020-09-13 10:27:01 +02:00
field_name='latitude',
min_value=-90,
max_value=90
)
def test_longitude(self):
2020-09-13 13:30:47 +02:00
self.assertFloatField(
2020-09-13 10:27:01 +02:00
field_name='longitude',
min_value=-180,
max_value=180
)