lostplaces-backend/django_lostplaces/lostplaces/tests/models/test_abstract_models.py
reverend 547179b0ca Squashed commit of the following:
commit 97b044cafb7f17f23b3b1beedcf70af209a60ddc
Author: reverend <reverend@reverend2048.de>
Date:   Mon Sep 14 17:25:40 2020 +0200

    Updating gitignore

commit 4891d80486e1f95db8ae66385c7c97426a3ca1a4
Author: reverend <reverend@reverend2048.de>
Date:   Mon Sep 14 17:25:20 2020 +0200

    Updating Readme

commit f05c43abbdc7eb30896ad6d10fe80fd6483338d9
Author: reverend <reverend@reverend2048.de>
Date:   Mon Sep 14 17:23:30 2020 +0200

    Renaming Module

commit fd5ad2ee9f8cbacd565da45b257928192ffc651c
Author: reverend <reverend@reverend2048.de>
Date:   Mon Sep 14 17:23:16 2020 +0200

    Renaming module references

commit 828a0dd5dd73723b84b77908497903ed26b6966b
Author: reverend <reverend@reverend2048.de>
Date:   Mon Sep 14 17:21:20 2020 +0200

    Renaming Project
2020-09-14 17:26:17 +02:00

93 lines
2.2 KiB
Python

import datetime
from django.test import TestCase
from django.db import models
from django.contrib.auth.models import User
from lostplaces.models import (
Taggable,
Mapable,
Submittable
)
from lostplaces.tests.models import ModelTestCase
from taggit.managers import TaggableManager
class TaggableTestCase(ModelTestCase):
model = Taggable
def test_tags(self):
self.assertField('tags', TaggableManager)
class MapableTestCase(ModelTestCase):
model = Mapable
def test_name(self):
self.assertCharField(
field_name='name',
min_length=10,
max_length=100
)
def test_latitude(self):
self.assertFloatField(
field_name='latitude',
min_value=-90,
max_value=90
)
def test_longitude(self):
self.assertFloatField(
field_name='longitude',
min_value=-180,
max_value=180
)
class SubmittableTestCase(ModelTestCase):
model = Submittable
def test_submitted_when(self):
self.assertField(
field_name='submitted_when',
field_class=models.DateTimeField,
must_have={'auto_now_add': True}
)
def test_submitted_by(self):
submitted_by = self.assertField(
field_name='submitted_by',
field_class=models.ForeignKey
)
self.assertEqual(
submitted_by.remote_field.related_name,
'%(class)s',
msg='Expecting the related_name of %s to be \'%%(class)s\', got %s' % (
str(submitted_by),
submitted_by.remote_field.related_name
)
)
self.assertTrue(
submitted_by.null,
msg='Expecting %s to has null=True' % (
str(submitted_by)
)
)
self.assertTrue(
submitted_by.blank,
msg='Expecting %s to has blank=True' % (
str(submitted_by)
)
)
self.assertEqual(
submitted_by.remote_field.on_delete,
models.SET_NULL,
msg='Expecting %s to be null when reference is delete (models.SET_NULL)' % (
str(submitted_by)
)
)