mirror of
https://github.com/azaion/loader.git
synced 2026-04-22 21:56:33 +00:00
8f7deb3fca
Made-with: Cursor
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
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
|