forked from nupurmadaan04/SOUL_SENSE_EXAM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_schemas.py
More file actions
48 lines (41 loc) · 1.39 KB
/
verify_schemas.py
File metadata and controls
48 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
import os
# Add project root to path
sys.path.append(os.getcwd())
from backend.fastapi.api.schemas import UserCreate, UserLogin, UserUpdate, PersonalProfileUpdate
from pydantic import ValidationError
def test_user_create():
print("Testing UserCreate...")
user = UserCreate(
username=" User123 ",
email=" Test@Example.COM ",
password="Password123!",
first_name=" John ",
last_name=" Doe ",
age=25,
gender="Male"
)
print(f"✅ Normalization: {user.username=}, {user.email=}")
assert user.username == "user123"
assert user.email == "test@example.com"
def test_user_update():
print("\nTesting UserUpdate...")
# Test Normalization
user = UserUpdate(username=" NewUser ")
print(f"✅ Normalization: {user.username=}")
assert user.username == "newuser"
# Test Reserved Username
try:
UserUpdate(username="support")
print("❌ Reserved username check failed")
except ValidationError:
print("✅ Reserved username blocked")
def test_profile_update():
print("\nTesting PersonalProfileUpdate...")
profile = PersonalProfileUpdate(email=" NEW_EMAIL@example.com ")
print(f"✅ Normalization: {profile.email=}")
assert profile.email == "new_email@example.com"
if __name__ == "__main__":
test_user_create()
test_user_update()
test_profile_update()