bookwyrm/fedireads/tests/test_base_model.py

32 lines
1,009 B
Python
Raw Normal View History

2020-05-12 21:45:30 +00:00
''' testing models '''
from django.test import TestCase
2020-05-12 22:07:31 +00:00
from fedireads import models
2020-05-12 21:45:30 +00:00
from fedireads.models.base_model import FedireadsModel
from fedireads.settings import DOMAIN
class BaseModel(TestCase):
def test_absolute_id(self):
instance = FedireadsModel()
instance.id = 1
expected = instance.absolute_id
self.assertEqual(expected, 'https://%s/fedireadsmodel/1' % DOMAIN)
2020-05-12 21:59:14 +00:00
def test_absolute_id_with_remote(self):
instance = FedireadsModel()
instance.remote_id = 'boop doop'
expected = instance.absolute_id
self.assertEqual(expected, 'boop doop')
2020-05-12 22:07:31 +00:00
def test_absolute_id_with_user(self):
user = models.User.objects.create_user(
'mouse', 'mouse@mouse.com', 'mouseword')
instance = FedireadsModel()
instance.user = user
instance.id = 1
expected = instance.absolute_id
self.assertEqual(
expected,
'https://%s/user/mouse/fedireadsmodel/1' % DOMAIN)