forked from mirrors/bookwyrm
user model tests
This commit is contained in:
parent
768ce1e5e7
commit
ab7acc6db6
1 changed files with 35 additions and 0 deletions
35
fedireads/tests/test_user_model.py
Normal file
35
fedireads/tests/test_user_model.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
''' testing models '''
|
||||
from django.test import TestCase
|
||||
|
||||
from fedireads import models
|
||||
from fedireads.settings import DOMAIN
|
||||
|
||||
|
||||
class User(TestCase):
|
||||
def setUp(self):
|
||||
models.User.objects.create_user(
|
||||
'mouse', 'mouse@mouse.mouse', 'mouseword')
|
||||
|
||||
def test_computed_fields(self):
|
||||
''' username instead of id here '''
|
||||
user = models.User.objects.get(localname='mouse')
|
||||
expected_id = 'https://%s/user/mouse' % DOMAIN
|
||||
self.assertEqual(user.absolute_id, expected_id)
|
||||
self.assertEqual(user.username, 'mouse@%s' % DOMAIN)
|
||||
self.assertEqual(user.localname, 'mouse')
|
||||
self.assertEqual(user.actor, 'https://%s/user/mouse' % DOMAIN)
|
||||
self.assertEqual(user.shared_inbox, 'https://%s/inbox' % DOMAIN)
|
||||
self.assertEqual(user.inbox, '%s/inbox' % expected_id)
|
||||
self.assertEqual(user.outbox, '%s/outbox' % expected_id)
|
||||
self.assertIsNotNone(user.private_key)
|
||||
self.assertIsNotNone(user.public_key)
|
||||
|
||||
|
||||
def test_user_shelves(self):
|
||||
user = models.User.objects.get(localname='mouse')
|
||||
shelves = models.Shelf.objects.filter(user=user).all()
|
||||
self.assertEqual(len(shelves), 3)
|
||||
names = [s.name for s in shelves]
|
||||
self.assertEqual(names, ['To Read', 'Currently Reading', 'Read'])
|
||||
ids = [s.identifier for s in shelves]
|
||||
self.assertEqual(ids, ['to-read', 'reading', 'read'])
|
Loading…
Reference in a new issue