2020-05-10 00:10:02 +00:00
|
|
|
''' testing models '''
|
|
|
|
from django.test import TestCase
|
|
|
|
|
2020-09-21 15:10:37 +00:00
|
|
|
from bookwyrm import models, settings
|
2020-05-10 00:10:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Status(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
user = models.User.objects.create_user(
|
2020-12-04 01:18:23 +00:00
|
|
|
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
|
2020-05-10 00:10:02 +00:00
|
|
|
book = models.Edition.objects.create(title='Example Edition')
|
|
|
|
|
|
|
|
models.Status.objects.create(user=user, content='Blah blah')
|
|
|
|
models.Comment.objects.create(user=user, content='content', book=book)
|
|
|
|
models.Quotation.objects.create(
|
|
|
|
user=user, content='content', book=book, quote='blah')
|
|
|
|
models.Review.objects.create(
|
|
|
|
user=user, content='content', book=book, rating=3)
|
|
|
|
|
|
|
|
def test_status(self):
|
|
|
|
status = models.Status.objects.first()
|
|
|
|
expected_id = 'https://%s/user/mouse/status/%d' % \
|
|
|
|
(settings.DOMAIN, status.id)
|
2020-05-13 01:56:28 +00:00
|
|
|
self.assertEqual(status.remote_id, expected_id)
|
2020-05-10 00:10:02 +00:00
|
|
|
|
|
|
|
def test_comment(self):
|
|
|
|
comment = models.Comment.objects.first()
|
|
|
|
expected_id = 'https://%s/user/mouse/comment/%d' % \
|
|
|
|
(settings.DOMAIN, comment.id)
|
2020-05-13 01:56:28 +00:00
|
|
|
self.assertEqual(comment.remote_id, expected_id)
|
2020-05-10 00:10:02 +00:00
|
|
|
|
|
|
|
def test_quotation(self):
|
|
|
|
quotation = models.Quotation.objects.first()
|
|
|
|
expected_id = 'https://%s/user/mouse/quotation/%d' % \
|
|
|
|
(settings.DOMAIN, quotation.id)
|
2020-05-13 01:56:28 +00:00
|
|
|
self.assertEqual(quotation.remote_id, expected_id)
|
2020-05-10 00:10:02 +00:00
|
|
|
|
|
|
|
def test_review(self):
|
|
|
|
review = models.Review.objects.first()
|
|
|
|
expected_id = 'https://%s/user/mouse/review/%d' % \
|
|
|
|
(settings.DOMAIN, review.id)
|
2020-05-13 01:56:28 +00:00
|
|
|
self.assertEqual(review.remote_id, expected_id)
|