Skip to content

Commit c3d0754

Browse files
User request test
1 parent 3f5f167 commit c3d0754

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

accounts/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from rest_framework_json_api import serializers, relations
1+
from rest_framework_json_api import serializers
22
from accounts.models import User
33

44

accounts/tests/__init__.py

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from django.test import TestCase
2+
from rest_framework.test import APIClient, APITestCase
3+
from accounts.models import User
4+
import sure
5+
import json
6+
7+
8+
class UserApiTests(APITestCase):
9+
def setUp(self):
10+
self.client = APIClient()
11+
self.content_type = 'application/vnd.api+json'
12+
13+
def test_patient_current_user_get(self):
14+
"""
15+
Ensure we get a user.
16+
"""
17+
user = User.objects.create(username="helloworld")
18+
19+
response = self.client.get("/services/api/users",
20+
content_type=self.content_type)
21+
22+
response.status_code.should.equal(200)
23+
24+
response_data = json.loads(response.content)
25+
attributes = json.loads(response.content)['data'][0]['attributes']
26+
attributes['username'].should.equal(user.username)

api/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,3 @@
147147
STATIC_URL = '/static/'
148148

149149
AUTH_USER_MODEL = 'accounts.User'
150-

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Django==2.1.2
22
psycopg2-binary==2.7.5
33
djangorestframework==3.8.2
4-
djangorestframework-jsonapi==2.2.0
4+
djangorestframework-jsonapi==2.2.0
5+
sure==1.4.11

0 commit comments

Comments
 (0)