@@ -20,76 +20,78 @@ async def test_demo(self, easy_api_client):
20
20
client = easy_api_client (PermissionAPIController )
21
21
22
22
response = await client .get (
23
- "/must_be_authenticated?word=authenticated" , content_type = "application/json"
23
+ "/must_be_authenticated/?word=authenticated" ,
24
+ content_type = "application/json" ,
24
25
)
26
+ print (f"{ response .__dict__ .items ()} " )
25
27
assert response .status_code == 200
26
28
assert response .json ().get ("data" )["says" ] == "authenticated"
27
29
28
30
client = easy_api_client (PermissionAPIController )
29
31
response = await client .get (
30
- "/must_be_admin_user?word=admin" ,
32
+ "/must_be_admin_user/ ?word=admin" ,
31
33
)
32
34
assert response .status_code == 403
33
35
with pytest .raises (KeyError ):
34
36
assert response .json ().get ("data" )["says" ] == "admin"
35
37
36
38
client = easy_api_client (PermissionAPIController , is_staff = True )
37
39
response = await client .get (
38
- "/must_be_admin_user?word=admin" ,
40
+ "/must_be_admin_user/ ?word=admin" ,
39
41
)
40
42
assert response .status_code == 200
41
43
assert response .json ().get ("data" )["says" ] == "admin"
42
44
43
45
client = easy_api_client (PermissionAPIController )
44
46
response = await client .get (
45
- "/must_be_super_user?word=superuser" ,
47
+ "/must_be_super_user/ ?word=superuser" ,
46
48
)
47
49
assert response .status_code == 403
48
50
with pytest .raises (KeyError ):
49
51
assert response .json ().get ("data" )["says" ] == "superuser"
50
52
51
53
client = easy_api_client (PermissionAPIController , is_superuser = True )
52
54
response = await client .get (
53
- "/must_be_super_user?word=superuser" ,
55
+ "/must_be_super_user/ ?word=superuser" ,
54
56
)
55
57
assert response .status_code == 200
56
58
assert response .json ().get ("data" )["says" ] == "superuser"
57
59
58
60
async def test_perm (self , transactional_db , easy_api_client ):
59
61
client = easy_api_client (PermissionAPIController )
60
- response = await client .get ("/test_perm" , query = dict (word = "normal" ))
62
+ response = await client .get ("/test_perm/ " , query = dict (word = "normal" ))
61
63
assert response .status_code == 200
62
64
assert response .json ().get ("data" )["says" ] == "normal"
63
65
client = easy_api_client (PermissionAPIController , is_staff = True )
64
- response = await client .get ("/test_perm" , query = dict (word = "staff" ))
66
+ response = await client .get ("/test_perm/ " , query = dict (word = "staff" ))
65
67
assert response .status_code == 200
66
68
assert response .json ().get ("data" )["says" ] == "staff"
67
69
68
70
async def test_perm_only_super (self , transactional_db , easy_api_client ):
69
71
client = easy_api_client (PermissionAPIController )
70
- response = await client .get ("/test_perm_only_super" )
72
+ response = await client .get ("/test_perm_only_super/ " )
71
73
assert response .status_code == 403
72
74
assert response .json ().get ("data" ) == {
73
75
"detail" : "You do not have permission to perform this action."
74
76
}
75
77
76
78
client = easy_api_client (PermissionAPIController )
77
- response = await client .get ("/test_perm_only_super" )
79
+ response = await client .get ("/test_perm_only_super/ " )
78
80
assert response .status_code == 403
79
81
assert response .json ().get ("data" ) == {
80
82
"detail" : "You do not have permission to perform this action."
81
83
}
82
84
83
85
client = easy_api_client (PermissionAPIController , is_superuser = True )
84
- response = await client .get ("/test_perm_only_super" )
86
+ response = await client .get ("/test_perm_only_super/ " )
85
87
assert response .status_code == 200
86
88
assert response .json ().get ("data" )["title" ] == "test_event_title"
87
89
88
90
async def test_perm_admin_site (self , transactional_db , easy_api_client ):
89
91
# None-admin users
90
92
client = easy_api_client (PermissionAPIController )
91
93
response = await client .get (
92
- "/test_perm_admin_site" , query = dict (word = "non-admin" )
94
+ "/test_perm_admin_site/ " , query = dict (word = "non-admin" )
93
95
)
94
96
assert response .status_code == 403
95
97
assert response .json ().get ("data" ) == {
@@ -98,7 +100,7 @@ async def test_perm_admin_site(self, transactional_db, easy_api_client):
98
100
99
101
# Staff users
100
102
client = easy_api_client (PermissionAPIController , is_staff = True )
101
- response = await client .get ("/test_perm_admin_site" , query = dict (word = "staff" ))
103
+ response = await client .get ("/test_perm_admin_site/ " , query = dict (word = "staff" ))
102
104
assert response .status_code == 200
103
105
assert response .json ()["data" ]["says" ] == "staff"
104
106
@@ -109,12 +111,12 @@ async def test_perm_auto_apis_delete(self, transactional_db, easy_api_client):
109
111
object_data .update (title = f"{ object_data ['title' ]} _get" )
110
112
event = await sync_to_async (Event .objects .create )(** object_data )
111
113
response = await client .get (
112
- f"/?pk= { event .id } " ,
114
+ f"/{ event .id } " ,
113
115
)
114
116
assert response .status_code == 403
115
117
116
118
response = await client .delete (
117
- f"/?pk= { event .id } " ,
119
+ f"/{ event .id } " ,
118
120
)
119
121
assert response .status_code == 403
120
122
assert response .json ().get ("data" ) == {
@@ -124,11 +126,11 @@ async def test_perm_auto_apis_delete(self, transactional_db, easy_api_client):
124
126
# Super users
125
127
client = easy_api_client (AutoGenCrudAPIController , is_superuser = True )
126
128
await client .delete (
127
- f"/?pk= { event .id } " ,
129
+ f"/{ event .id } " ,
128
130
)
129
131
130
132
response = await client .get (
131
- f"/?pk= { event .id } " ,
133
+ f"/{ event .id } " ,
132
134
)
133
135
assert response .status_code == 200
134
136
assert response .json ().get ("code" ) == 404
@@ -140,7 +142,7 @@ async def test_perm_auto_apis_patch(self, transactional_db, easy_api_client):
140
142
event = await sync_to_async (Event .objects .create )(** object_data )
141
143
142
144
response = await client .get (
143
- f"/?pk= { event .id } " ,
145
+ f"/{ event .id } " ,
144
146
)
145
147
assert response .status_code == 403
146
148
assert response .json ().get ("data" ) == {
@@ -150,7 +152,7 @@ async def test_perm_auto_apis_patch(self, transactional_db, easy_api_client):
150
152
# Staff users
151
153
client = easy_api_client (AutoGenCrudAPIController , is_staff = True )
152
154
response = await client .get (
153
- f"/?pk= { event .id } " ,
155
+ f"/{ event .id } " ,
154
156
)
155
157
assert response .json ().get ("data" )["title" ] == f"{ object_data ['title' ]} "
156
158
@@ -172,7 +174,7 @@ async def test_perm_auto_apis_patch(self, transactional_db, easy_api_client):
172
174
173
175
client = easy_api_client (AdminSitePermissionAPIController )
174
176
response = await client .patch (
175
- f"/?pk= { event .id } " , json = new_data , content_type = "application/json"
177
+ f"/{ event .id } " , json = new_data , content_type = "application/json"
176
178
)
177
179
178
180
assert response .status_code == 403
@@ -183,12 +185,12 @@ async def test_perm_auto_apis_patch(self, transactional_db, easy_api_client):
183
185
# Super users
184
186
client = easy_api_client (AutoGenCrudAPIController , is_superuser = True )
185
187
response = await client .patch (
186
- f"/?pk= { event .id } " , json = new_data , content_type = "application/json"
188
+ f"/{ event .id } " , json = new_data , content_type = "application/json"
187
189
)
188
190
assert response .json ().get ("data" )["pk" ] == event .id
189
191
190
192
response = await client .get (
191
- f"/?pk= { event .id } " ,
193
+ f"/{ event .id } " ,
192
194
)
193
195
assert response .status_code == 200
194
196
assert response .json ().get ("data" )["title" ] == "AsyncAPIEvent_patch"
0 commit comments