Fixes model tests

This commit is contained in:
Mouse Reeve
2021-03-23 10:41:18 -07:00
parent 9e23bfe7c0
commit 7f271dbde7
4 changed files with 54 additions and 50 deletions

View File

@ -27,18 +27,18 @@ class BaseModel(TestCase):
expected = instance.get_remote_id()
self.assertEqual(expected, "https://%s/user/mouse/bookwyrmmodel/1" % DOMAIN)
def test_execute_after_save(self):
def test_set_remote_id(self):
""" this function sets remote ids after creation """
# using Work because it BookWrymModel is abstract and this requires save
# Work is a relatively not-fancy model.
instance = models.Work.objects.create(title="work title")
instance.remote_id = None
base_model.execute_after_save(None, instance, True)
base_model.set_remote_id(None, instance, True)
self.assertEqual(
instance.remote_id, "https://%s/book/%d" % (DOMAIN, instance.id)
)
# shouldn't set remote_id if it's not created
instance.remote_id = None
base_model.execute_after_save(None, instance, False)
base_model.set_remote_id(None, instance, False)
self.assertIsNone(instance.remote_id)