File tree Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Expand file tree Collapse file tree 2 files changed +16
-15
lines changed Original file line number Diff line number Diff line change 1
- from rest_framework import status , serializers
1
+ from rest_framework import status
2
2
from rest_framework .test import APITestCase
3
3
from rest_framework_jwt .settings import api_settings
4
- from django .core .management import call_command
5
4
6
5
jwt_payload_handler = api_settings .JWT_PAYLOAD_HANDLER
7
6
jwt_encode_handler = api_settings .JWT_ENCODE_HANDLER
8
7
9
8
class ResourcesTests (APITestCase ):
10
9
11
- def setUp (self ):
12
- call_command ('loaddata' , 'users.json' , verbosity = 0 )
13
- call_command ('loaddata' , 'resources.json' , verbosity = 0 )
14
- call_command ('loaddata' , 'tagging.json' , verbosity = 0 )
15
- call_command ('loaddata' , 'taggeditems.json' , verbosity = 0 )
10
+ fixtures = [
11
+ 'users' ,
12
+ 'resources' ,
13
+ 'tagging' ,
14
+ 'taggeditems'
15
+ ]
16
16
17
+ def setUp (self ):
17
18
url = '/auth/obtain_token/'
18
19
#to do: choose a user at random from loaded users.json
19
20
data = {"username" : "JuJu" , "password" : "codebuddies" }
Original file line number Diff line number Diff line change 1
- import unittest
2
1
from unittest .mock import patch
3
2
from rest_framework import status , serializers
4
3
from rest_framework .test import APITestCase
5
4
from rest_framework_jwt .settings import api_settings
6
- from django .core .management import call_command
7
5
from django .contrib .auth import get_user_model
8
6
9
7
12
10
13
11
class UserauthTests (APITestCase ):
14
12
13
+ fixtures = ['users' ]
14
+
15
15
def setUp (self ):
16
- """
17
- Loads users.json fixture into test DB and directly creates a new user.
18
- """
19
- call_command ('loaddata' , 'users.json' , verbosity = 0 )
16
+ # create a new user
20
17
model = get_user_model ()
21
- self .
person = model .
objects .
create_user (
username = 'PetuniaPig' ,
email = '[email protected] ' ,
22
- password = 'codebuddies' )
18
+ self .person = model .objects .create_user (
19
+ username = 'PetuniaPig' ,
20
+
21
+ password = 'codebuddies'
22
+ )
23
23
24
24
25
25
def test_jwt_not_authed (self ):
You can’t perform that action at this time.
0 commit comments