Tests base model absolute id generator

This commit is contained in:
Mouse Reeve 2020-05-12 14:45:30 -07:00
parent 4190793f17
commit bebb4d465b
2 changed files with 14 additions and 1 deletions

View file

@ -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

View 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)