2020-05-12 21:45:30 +00:00
|
|
|
''' testing models '''
|
|
|
|
from django.test import TestCase
|
|
|
|
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm import models
|
2020-09-21 15:22:58 +00:00
|
|
|
from bookwyrm.models.base_model import BookWyrmModel
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm.settings import DOMAIN
|
2020-05-12 21:45:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
class BaseModel(TestCase):
|
2020-05-13 01:56:28 +00:00
|
|
|
def test_remote_id(self):
|
2020-09-21 15:22:58 +00:00
|
|
|
instance = BookWyrmModel()
|
2020-05-12 21:45:30 +00:00
|
|
|
instance.id = 1
|
2020-05-13 01:56:28 +00:00
|
|
|
expected = instance.get_remote_id()
|
2020-09-21 15:10:37 +00:00
|
|
|
self.assertEqual(expected, 'https://%s/bookwyrmmodel/1' % DOMAIN)
|
2020-05-12 21:59:14 +00:00
|
|
|
|
2020-05-13 01:56:28 +00:00
|
|
|
def test_remote_id_with_user(self):
|
2020-05-12 22:07:31 +00:00
|
|
|
user = models.User.objects.create_user(
|
|
|
|
'mouse', 'mouse@mouse.com', 'mouseword')
|
2020-09-21 15:22:58 +00:00
|
|
|
instance = BookWyrmModel()
|
2020-05-12 22:07:31 +00:00
|
|
|
instance.user = user
|
|
|
|
instance.id = 1
|
2020-05-13 01:56:28 +00:00
|
|
|
expected = instance.get_remote_id()
|
2020-05-12 22:07:31 +00:00
|
|
|
self.assertEqual(
|
|
|
|
expected,
|
2020-09-21 15:10:37 +00:00
|
|
|
'https://%s/user/mouse/bookwyrmmodel/1' % DOMAIN)
|