31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from django.db import models as django_models
|
|
from lostplaces_app.models import Explorer
|
|
|
|
|
|
def mock_user():
|
|
explorer_list = Explorer.objects.all()
|
|
if len(explorer_list) <= 0:
|
|
return Explorer.objects.create_user(
|
|
username='testpeter',
|
|
password='Develop123'
|
|
)
|
|
else:
|
|
return explorer_list[0]
|
|
|
|
|
|
class TestSubmittable:
|
|
|
|
def test_submitted_when(self):
|
|
submitted_when = self.object._meta.get_field('submitted_when')
|
|
self.assertTrue(submitted_when)
|
|
self.assertEqual(type(submitted_when), django_models.DateTimeField)
|
|
self.assertTrue(submitted_when.auto_now_add)
|
|
|
|
def test_submitted_by(self):
|
|
submitted_by = self.object._meta.get_field('submitted_by')
|
|
self.assertTrue(submitted_by)
|
|
self.assertEqual(type(submitted_by), django_models.ForeignKey)
|
|
self.assertEqual(submitted_by.remote_field.related_name, 'places')
|
|
self.assertTrue(submitted_by.null)
|
|
self.assertTrue(submitted_by.blank)
|
|
self.assertEqual(submitted_by.remote_field.on_delete, django_models.SET_NULL) |