mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 10:36:32 +00:00
Add E2E tests, fix bugs
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
def test_status_unauthenticated(base_url, api_client):
|
||||
# Act
|
||||
response = api_client.get(f"{base_url}/status")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert response.json()["authenticated"] is False
|
||||
|
||||
|
||||
def test_download_unauthenticated(base_url, api_client):
|
||||
# Arrange
|
||||
url = f"{base_url}/load/testmodel"
|
||||
body = {"filename": "testmodel", "folder": "models"}
|
||||
|
||||
# Act
|
||||
response = api_client.post(url, json=body)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 500
|
||||
|
||||
|
||||
def test_login_invalid_credentials(base_url, api_client):
|
||||
# Arrange
|
||||
payload = {"email": "wrong@example.com", "password": "wrong"}
|
||||
|
||||
# Act
|
||||
response = api_client.post(f"{base_url}/login", json=payload)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 401
|
||||
|
||||
|
||||
def test_login_empty_body(base_url, api_client):
|
||||
# Act
|
||||
response = api_client.post(f"{base_url}/login", json={})
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 422
|
||||
|
||||
|
||||
def test_login_valid_credentials(base_url, api_client):
|
||||
# Arrange
|
||||
payload = {"email": "test@azaion.com", "password": "testpass"}
|
||||
|
||||
# Act
|
||||
response = api_client.post(f"{base_url}/login", json=payload)
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert response.json()["status"] == "ok"
|
||||
|
||||
|
||||
def test_status_authenticated_after_login(base_url, logged_in_client):
|
||||
# Act
|
||||
response = logged_in_client.get(f"{base_url}/status")
|
||||
|
||||
# Assert
|
||||
assert response.status_code == 200
|
||||
assert response.json()["authenticated"] is True
|
||||
Reference in New Issue
Block a user