-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_auth.py
More file actions
28 lines (21 loc) · 838 Bytes
/
test_auth.py
File metadata and controls
28 lines (21 loc) · 838 Bytes
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
# tests/integration/test_auth.py
import requests
import pytest
BASE_URL = 'http://localhost:5000'
def test_user_signup():
# Test invalid email
data = {'email': 'invalid', 'password': 'pass123'}
response = requests.post(f"{BASE_URL}/signup", json=data)
assert response.status_code == 400
# Test short password
data = {'email': 'validemail@test.com', 'password': 'short'}
response = requests.post(f"{BASE_URL}/signup", json=data)
assert response.status_code == 400
# Valid signup
data = {'email': 'validemail@test.com', 'password': 'goodpassword'}
response = requests.post(f"{BASE_URL}/signup", json=data)
assert response.status_code == 201
# Verify user was created
response = requests.get(f"{BASE_URL}/users")
users = response.json()
assert any(u['email'] == 'validemail@test.com' for u in users)