test_auth.py 837 B

123456789101112131415161718192021222324252627282930
  1. import requests
  2. def test_registration():
  3. url = "http://localhost:8000/auth/register"
  4. data = {
  5. "email": "test@example.com",
  6. "password": "password123",
  7. "first_name": "Test",
  8. "last_name": "User"
  9. }
  10. response = requests.post(url, json=data)
  11. print(f"Registration Status: {response.status_code}")
  12. print(f"Registration Response: {response.json()}")
  13. def test_login():
  14. url = "http://localhost:8000/auth/login"
  15. data = {
  16. "email": "test@example.com",
  17. "password": "password123"
  18. }
  19. response = requests.post(url, json=data)
  20. print(f"Login Status: {response.status_code}")
  21. print(f"Login Response: {response.json()}")
  22. if __name__ == "__main__":
  23. try:
  24. test_registration()
  25. test_login()
  26. except Exception as e:
  27. print(f"Error: {e}")