1
1
import os
2
2
3
+ from fastapi import status
3
4
from PIL import Image
4
5
import pytest
5
6
@@ -31,7 +32,7 @@ def test_get_image_crop_area(width, height, result):
31
32
def test_profile_page (profile_test_client ):
32
33
profile = profile_test_client .get ('/profile' )
33
34
data = profile .content
34
- assert profile .status_code == 200
35
+ assert profile .ok
35
36
assert b'profile.png' in data
36
37
assert b'FakeName' in data
37
38
assert b'Happy new user!' in data
@@ -47,7 +48,7 @@ def test_update_user_fullname(profile_test_client):
47
48
# Post new data
48
49
profile = profile_test_client .post (
49
50
'/profile/update_user_fullname' , data = new_name_data )
50
- assert profile .status_code == 302
51
+ assert profile .status_code == status . HTTP_302_FOUND
51
52
52
53
# Get updated data
53
54
data = profile_test_client .get ('/profile' ).content
@@ -64,7 +65,7 @@ def test_update_user_email(profile_test_client):
64
65
# Post new data
65
66
profile = profile_test_client .post (
66
67
'/profile/update_user_email' , data = new_email )
67
- assert profile .status_code == 302
68
+ assert profile .status_code == status . HTTP_302_FOUND
68
69
69
70
# Get updated data
70
71
data = profile_test_client .get ('/profile' ).content
@@ -81,7 +82,7 @@ def test_update_user_description(profile_test_client):
81
82
# Post new data
82
83
profile = profile_test_client .post (
83
84
'/profile/update_user_description' , data = new_description )
84
- assert profile .status_code == 302
85
+ assert profile .status_code == status . HTTP_302_FOUND
85
86
86
87
# Get updated data
87
88
data = profile_test_client .get ('/profile' ).content
@@ -98,7 +99,7 @@ def test_update_telegram_id(profile_test_client):
98
99
# Post new data
99
100
profile = profile_test_client .post (
100
101
'/profile/update_telegram_id' , data = new_telegram_id )
101
- assert profile .status_code == 302
102
+ assert profile .status_code == status . HTTP_302_FOUND
102
103
103
104
# Get updated data
104
105
data = profile_test_client .get ('/profile' ).content
@@ -116,7 +117,7 @@ def test_upload_user_photo(profile_test_client):
116
117
'/profile/upload_user_photo' ,
117
118
files = {'file' : (
118
119
"filename" , open (example_new_photo , "rb" ), "image/png" )})
119
- assert profile .status_code == 302
120
+ assert profile .status_code == status . HTTP_302_FOUND
120
121
121
122
# Validate new picture saved in media directory
122
123
assert 'fake_user.png' in os .listdir (MEDIA_PATH )
0 commit comments