30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
from django.db import 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), 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), 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, models.SET_NULL) |