2025-11-08 18:20:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_index_get(client):
|
|
|
|
|
resp = await client.get("/")
|
|
|
|
|
assert resp.status == 200
|
|
|
|
|
text = await resp.text()
|
2025-11-08 18:59:06 +01:00
|
|
|
assert "Elevate Your Business Data" in text
|
|
|
|
|
assert "Start Free Trial" in text
|
|
|
|
|
|
2025-11-08 18:20:25 +01:00
|
|
|
|
|
|
|
|
async def test_dashboard_get_unauthorized(client):
|
|
|
|
|
resp = await client.get("/dashboard", allow_redirects=False)
|
|
|
|
|
assert resp.status == 302
|
|
|
|
|
assert resp.headers["Location"] == "/login"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_dashboard_get_authorized(client):
|
|
|
|
|
await client.post(
|
|
|
|
|
"/register",
|
|
|
|
|
data={
|
2025-11-08 18:59:06 +01:00
|
|
|
"full_name": "Test User",
|
2025-11-08 18:20:25 +01:00
|
|
|
"email": "test@example.com",
|
|
|
|
|
"password": "password",
|
|
|
|
|
"confirm_password": "password",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
await client.post(
|
|
|
|
|
"/login", data={"email": "test@example.com", "password": "password"}
|
|
|
|
|
)
|
|
|
|
|
resp = await client.get("/dashboard")
|
|
|
|
|
assert resp.status == 200
|
|
|
|
|
text = await resp.text()
|
2025-11-08 18:59:06 +01:00
|
|
|
assert "Your Data, Organized and Accessible" in text
|
|
|
|
|
assert "My Files" in text
|
2025-11-08 18:20:25 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_order_post_unauthorized(client):
|
|
|
|
|
resp = await client.post(
|
|
|
|
|
"/order", data={"storage_amount": "10.5"}, allow_redirects=False
|
|
|
|
|
)
|
|
|
|
|
assert resp.status == 302
|
|
|
|
|
assert resp.headers["Location"] == "/login"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_order_post_authorized(client):
|
|
|
|
|
await client.post(
|
|
|
|
|
"/register",
|
|
|
|
|
data={
|
2025-11-08 18:59:06 +01:00
|
|
|
"full_name": "Test User",
|
2025-11-08 18:20:25 +01:00
|
|
|
"email": "test@example.com",
|
|
|
|
|
"password": "password",
|
|
|
|
|
"confirm_password": "password",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
await client.post(
|
|
|
|
|
"/login", data={"email": "test@example.com", "password": "password"}
|
|
|
|
|
)
|
|
|
|
|
resp = await client.post("/order", data={"storage_amount": "10.5"}, allow_redirects=False)
|
|
|
|
|
assert resp.status == 302
|
|
|
|
|
assert resp.headers["Location"] == "/dashboard"
|
|
|
|
|
|
|
|
|
|
# Verify that the user's quota was updated
|
|
|
|
|
user_service = client.app["user_service"]
|
|
|
|
|
user = user_service.get_user_by_email("test@example.com")
|
|
|
|
|
assert user["storage_quota_gb"] == 10.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def test_order_post_invalid_amount(client):
|
|
|
|
|
await client.post(
|
|
|
|
|
"/register",
|
|
|
|
|
data={
|
2025-11-08 18:59:06 +01:00
|
|
|
"full_name": "Test User",
|
2025-11-08 18:20:25 +01:00
|
|
|
"email": "test@example.com",
|
|
|
|
|
"password": "password",
|
|
|
|
|
"confirm_password": "password",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
await client.post(
|
|
|
|
|
"/login", data={"email": "test@example.com", "password": "password"}
|
|
|
|
|
)
|
|
|
|
|
resp = await client.post("/order", data={"storage_amount": "0"})
|
|
|
|
|
assert resp.status == 200
|
|
|
|
|
text = await resp.text()
|
|
|
|
|
assert "ensure this value is greater than 0" in text
|
|
|
|
|
|
|
|
|
|
resp = await client.post("/order", data={"storage_amount": "1001"})
|
|
|
|
|
assert resp.status == 200
|
|
|
|
|
text = await resp.text()
|
|
|
|
|
assert "ensure this value is less than or equal to 1000" in text
|