File tree Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Expand file tree Collapse file tree 5 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
- from rest_framework_json_api import serializers , relations
1
+ from rest_framework_json_api import serializers
2
2
from accounts .models import User
3
3
4
4
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change 147
147
STATIC_URL = '/static/'
148
148
149
149
AUTH_USER_MODEL = 'accounts.User'
150
-
Original file line number Diff line number Diff line change 1
1
Django == 2.1.2
2
2
psycopg2-binary == 2.7.5
3
3
djangorestframework == 3.8.2
4
- djangorestframework-jsonapi == 2.2.0
4
+ djangorestframework-jsonapi == 2.2.0
5
+ sure == 1.4.11
You can’t perform that action at this time.
0 commit comments