@@ -18,36 +18,36 @@ def client():
18
18
def test_get_list (client ):
19
19
repository_mock = mock .Mock (spec = UserRepository )
20
20
repository_mock .get_all .return_value = [
21
- User (id = 1 , email = ' test1@email.com' , hashed_password = ' pwd' , is_active = True ),
22
- User (id = 2 , email = ' test2@email.com' , hashed_password = ' pwd' , is_active = False ),
21
+ User (id = 1 , email = " test1@email.com" , hashed_password = " pwd" , is_active = True ),
22
+ User (id = 2 , email = " test2@email.com" , hashed_password = " pwd" , is_active = False ),
23
23
]
24
24
25
25
with app .container .user_repository .override (repository_mock ):
26
- response = client .get (' /users' )
26
+ response = client .get (" /users" )
27
27
28
28
assert response .status_code == 200
29
29
data = response .json ()
30
30
assert data == [
31
- {'id' : 1 , ' email' : ' test1@email.com' , ' hashed_password' : ' pwd' , ' is_active' : True },
32
- {'id' : 2 , ' email' : ' test2@email.com' , ' hashed_password' : ' pwd' , ' is_active' : False },
31
+ {"id" : 1 , " email" : " test1@email.com" , " hashed_password" : " pwd" , " is_active" : True },
32
+ {"id" : 2 , " email" : " test2@email.com" , " hashed_password" : " pwd" , " is_active" : False },
33
33
]
34
34
35
35
36
36
def test_get_by_id (client ):
37
37
repository_mock = mock .Mock (spec = UserRepository )
38
38
repository_mock .get_by_id .return_value = User (
39
39
id = 1 ,
40
- email = ' xyz@email.com' ,
41
- hashed_password = ' pwd' ,
40
+ email = " xyz@email.com" ,
41
+ hashed_password = " pwd" ,
42
42
is_active = True ,
43
43
)
44
44
45
45
with app .container .user_repository .override (repository_mock ):
46
- response = client .get (' /users/1' )
46
+ response = client .get (" /users/1" )
47
47
48
48
assert response .status_code == 200
49
49
data = response .json ()
50
- assert data == {'id' : 1 , ' email' : ' xyz@email.com' , ' hashed_password' : ' pwd' , ' is_active' : True }
50
+ assert data == {"id" : 1 , " email" : " xyz@email.com" , " hashed_password" : " pwd" , " is_active" : True }
51
51
repository_mock .get_by_id .assert_called_once_with (1 )
52
52
53
53
@@ -56,35 +56,35 @@ def test_get_by_id_404(client):
56
56
repository_mock .get_by_id .side_effect = UserNotFoundError (1 )
57
57
58
58
with app .container .user_repository .override (repository_mock ):
59
- response = client .get (' /users/1' )
59
+ response = client .get (" /users/1" )
60
60
61
61
assert response .status_code == 404
62
62
63
63
64
- @mock .patch (' webapp.services.uuid4' , return_value = ' xyz' )
64
+ @mock .patch (" webapp.services.uuid4" , return_value = " xyz" )
65
65
def test_add (_ , client ):
66
66
repository_mock = mock .Mock (spec = UserRepository )
67
67
repository_mock .add .return_value = User (
68
68
id = 1 ,
69
- email = ' xyz@email.com' ,
70
- hashed_password = ' pwd' ,
69
+ email = " xyz@email.com" ,
70
+ hashed_password = " pwd" ,
71
71
is_active = True ,
72
72
)
73
73
74
74
with app .container .user_repository .override (repository_mock ):
75
- response = client .post (' /users' )
75
+ response = client .post (" /users" )
76
76
77
77
assert response .status_code == 201
78
78
data = response .json ()
79
- assert data == {'id' : 1 , ' email' : ' xyz@email.com' , ' hashed_password' : ' pwd' , ' is_active' : True }
80
- repository_mock .add .assert_called_once_with (email = ' xyz@email.com' , password = ' pwd' )
79
+ assert data == {"id" : 1 , " email" : " xyz@email.com" , " hashed_password" : " pwd" , " is_active" : True }
80
+ repository_mock .add .assert_called_once_with (email = " xyz@email.com" , password = " pwd" )
81
81
82
82
83
83
def test_remove (client ):
84
84
repository_mock = mock .Mock (spec = UserRepository )
85
85
86
86
with app .container .user_repository .override (repository_mock ):
87
- response = client .delete (' /users/1' )
87
+ response = client .delete (" /users/1" )
88
88
89
89
assert response .status_code == 204
90
90
repository_mock .delete_by_id .assert_called_once_with (1 )
@@ -95,13 +95,13 @@ def test_remove_404(client):
95
95
repository_mock .delete_by_id .side_effect = UserNotFoundError (1 )
96
96
97
97
with app .container .user_repository .override (repository_mock ):
98
- response = client .delete (' /users/1' )
98
+ response = client .delete (" /users/1" )
99
99
100
100
assert response .status_code == 404
101
101
102
102
103
103
def test_status (client ):
104
- response = client .get (' /status' )
104
+ response = client .get (" /status" )
105
105
assert response .status_code == 200
106
106
data = response .json ()
107
- assert data == {' status' : 'OK' }
107
+ assert data == {" status" : "OK" }
0 commit comments