forked from mirrors/bookwyrm
Tests base model absolute id generator
This commit is contained in:
parent
4190793f17
commit
bebb4d465b
2 changed files with 14 additions and 1 deletions
|
@ -11,7 +11,7 @@ class FedireadsModel(models.Model):
|
|||
@property
|
||||
def absolute_id(self):
|
||||
''' constructs the absolute reference to any db object '''
|
||||
if self.remote_id:
|
||||
if hasattr(self, 'remote_id') and self.remote_id:
|
||||
return self.remote_id
|
||||
|
||||
base_path = 'https://%s' % DOMAIN
|
||||
|
|
13
fedireads/tests/test_base_model.py
Normal file
13
fedireads/tests/test_base_model.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
''' testing models '''
|
||||
from django.test import TestCase
|
||||
|
||||
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)
|
Loading…
Reference in a new issue