2019-05-14 21:48:18 +00:00
|
|
|
from django_kepi.activity_model import Activity
|
2019-05-05 01:43:14 +00:00
|
|
|
from django.test import TestCase, Client
|
2019-05-14 21:48:18 +00:00
|
|
|
from things_for_testing.models import ThingUser
|
2019-05-05 01:43:14 +00:00
|
|
|
import logging
|
2019-05-14 21:48:18 +00:00
|
|
|
import json
|
2019-05-05 01:43:14 +00:00
|
|
|
|
|
|
|
logger = logging.getLogger(name='django_kepi')
|
|
|
|
|
2019-05-14 21:48:18 +00:00
|
|
|
class TestSingleKepiView(TestCase):
|
2019-05-05 01:43:14 +00:00
|
|
|
|
2019-05-14 21:48:18 +00:00
|
|
|
def test_single_kepi_view(self):
|
2019-05-05 01:43:14 +00:00
|
|
|
|
2019-05-14 21:48:18 +00:00
|
|
|
alice = ThingUser(
|
|
|
|
name = 'alice',
|
|
|
|
favourite_colour = 'magenta',
|
2019-05-05 01:43:14 +00:00
|
|
|
)
|
2019-05-14 21:48:18 +00:00
|
|
|
alice.save()
|
2019-05-05 01:43:14 +00:00
|
|
|
|
|
|
|
c = Client()
|
2019-05-14 21:48:18 +00:00
|
|
|
response = c.get('/users/alice')
|
|
|
|
logger.info('Response: %s', response.content.decode('utf-8'))
|
|
|
|
result = json.loads(response.content.decode('utf-8'))
|
|
|
|
|
|
|
|
self.assertDictEqual(
|
|
|
|
result,
|
|
|
|
{
|
|
|
|
'name': 'alice',
|
|
|
|
'favourite_colour': 'magenta',
|
|
|
|
'id': 'https://altair.example.com/users/alice',
|
|
|
|
},
|
|
|
|
)
|