1
- import json
2
1
import socket
3
2
4
3
from fastapi .testclient import TestClient
@@ -10,38 +9,37 @@ def url_for(self, name, host=socket.gethostname()):
10
9
11
10
def get (self , endpoint ):
12
11
url = self .url_for (endpoint )
13
- return super ().get (url , cookies = self . cookies )
12
+ return super ().get (url )
14
13
15
14
def post (self , endpoint , data = None ):
16
15
url = self .url_for (endpoint )
17
16
response = super ().post (
18
17
url ,
19
18
json = data ,
20
19
headers = self .headers ,
21
- cookies = self .cookies ,
22
20
)
23
21
24
22
return response
25
23
26
24
def put (self , endpoint , data = None ):
27
25
url = self .url_for (endpoint )
28
- response = super ().put (url , json = data , cookies = self . cookies )
26
+ response = super ().put (url , json = data )
29
27
return response
30
28
31
29
def patch (self , endpoint , data = None ):
32
30
url = self .url_for (endpoint )
33
- response = super ().patch (url , json = data , cookies = self . cookies )
31
+ response = super ().patch (url , json = data )
34
32
return response
35
33
36
34
def delete (self , endpoint ):
37
35
url = self .url_for (endpoint )
38
- return super ().delete (url , cookies = self . cookies )
36
+ return super ().delete (url )
39
37
40
38
def login (self , user , endpoint = "/auth/login" ):
41
39
data = {
42
40
"email" : user .email ,
43
41
"password" : "Sekrit" ,
44
42
}
45
43
response = self .post (endpoint , data )
46
- setattr ( self , " cookies" , response .cookies )
44
+ self . cookies = response .cookies
47
45
return response
0 commit comments