Adds another shelf model test

This commit is contained in:
Mouse Reeve 2020-12-14 10:18:14 -08:00
parent 61041a0dba
commit badc5d0dab
1 changed files with 2 additions and 14 deletions

View File

@ -8,6 +8,7 @@ from bookwyrm.models.book import isbn_10_to_13, isbn_13_to_10
class Book(TestCase): class Book(TestCase):
''' not too much going on in the books model but here we are ''' ''' not too much going on in the books model but here we are '''
def setUp(self): def setUp(self):
''' we'll need some books '''
self.work = models.Work.objects.create( self.work = models.Work.objects.create(
title='Example Work', title='Example Work',
remote_id='https://example.com/book/1' remote_id='https://example.com/book/1'
@ -22,6 +23,7 @@ class Book(TestCase):
) )
def test_remote_id(self): def test_remote_id(self):
''' fanciness with remote/origin ids '''
remote_id = 'https://%s/book/%d' % (settings.DOMAIN, self.work.id) remote_id = 'https://%s/book/%d' % (settings.DOMAIN, self.work.id)
self.assertEqual(self.work.get_remote_id(), remote_id) self.assertEqual(self.work.get_remote_id(), remote_id)
self.assertEqual(self.work.remote_id, remote_id) self.assertEqual(self.work.remote_id, remote_id)
@ -54,17 +56,3 @@ class Book(TestCase):
isbn_13 = '978-1788-16167-1' isbn_13 = '978-1788-16167-1'
isbn_10 = isbn_13_to_10(isbn_13) isbn_10 = isbn_13_to_10(isbn_13)
self.assertEqual(isbn_10, '178816167X') self.assertEqual(isbn_10, '178816167X')
class Shelf(TestCase):
def setUp(self):
user = models.User.objects.create_user(
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
models.Shelf.objects.create(
name='Test Shelf', identifier='test-shelf', user=user)
def test_remote_id(self):
''' editions and works use the same absolute id syntax '''
shelf = models.Shelf.objects.get(identifier='test-shelf')
expected_id = 'https://%s/user/mouse/shelf/test-shelf' % settings.DOMAIN
self.assertEqual(shelf.get_remote_id(), expected_id)