chore: remove trailing whitespace from README.md line 42

This commit is contained in:
2025-11-08 17:59:06 +00:00
parent 8b61117744
commit d94fcc0507
66 changed files with 2714 additions and 743 deletions
+33
View File
@@ -0,0 +1,33 @@
import pytest
from pathlib import Path
import json
from retoors.main import create_app
from retoors.services.user_service import UserService
from retoors.services.config_service import ConfigService
@pytest.fixture
def client(event_loop, aiohttp_client):
app = create_app()
# Create temporary data files for testing
base_path = Path(__file__).parent.parent
data_path = base_path / "data"
data_path.mkdir(exist_ok=True)
users_file = data_path / "users.json"
with open(users_file, "w") as f:
json.dump([], f)
config_file = data_path / "config.json"
with open(config_file, "w") as f:
json.dump({"price_per_gb": 0.0}, f)
app["user_service"] = UserService(users_file)
app["config_service"] = ConfigService(config_file)
yield event_loop.run_until_complete(aiohttp_client(app))
# Clean up temporary files
users_file.unlink(missing_ok=True)
config_file.unlink(missing_ok=True)
+130
View File
@@ -0,0 +1,130 @@
async def test_login_get(client):
resp = await client.get("/login")
assert resp.status == 200
text = await resp.text()
assert "Access Your Retoor's Cloud Account" in text
assert "Login to your Account" in text
async def test_register_get(client):
resp = await client.get("/register")
assert resp.status == 200
text = await resp.text()
assert "Create Your Retoor's Cloud Account" in text
assert "Create an Account" in text
assert resp.url.path == "/register"
async def test_register_post_password_mismatch(client):
resp = await client.post(
"/register",
data={
"full_name": "Test User",
"email": "test@example.com",
"password": "password",
"confirm_password": "wrong_password",
},
)
assert resp.status == 200
text = await resp.text()
assert "Passwords do not match" in text
async def test_register_post_user_exists(client):
await client.post(
"/register",
data={
"full_name": "Test User",
"email": "test@example.com",
"password": "password",
"confirm_password": "password",
},
)
resp = await client.post(
"/register",
data={
"full_name": "Test User 2",
"email": "test@example.com",
"password": "password",
"confirm_password": "password",
},
)
assert resp.status == 200
text = await resp.text()
assert "User with this email already exists" in text
async def test_register_post_invalid_email(client):
resp = await client.post(
"/register",
data={
"full_name": "Test User",
"email": "invalid-email",
"password": "password",
"confirm_password": "password",
},
)
assert resp.status == 200
text = await resp.text()
assert "value is not a valid email address" in text
async def test_register_post_short_password(client):
resp = await client.post(
"/register",
data={
"full_name": "Test User",
"email": "test@example.com",
"password": "short",
"confirm_password": "short",
},
)
assert resp.status == 200
text = await resp.text()
assert "ensure this value has at least 8 characters" in text
async def test_login_post(client):
await client.post(
"/register",
data={
"full_name": "Test User",
"email": "test@example.com",
"password": "password",
"confirm_password": "password",
},
)
resp = await client.post(
"/login", data={"email": "test@example.com", "password": "password"}, allow_redirects=False
)
assert resp.status == 302
assert resp.headers["Location"] == "/dashboard"
async def test_login_post_invalid_credentials(client):
resp = await client.post(
"/login", data={"email": "test@example.com", "password": "wrong_password"}
)
assert resp.status == 200
text = await resp.text()
assert "Invalid email or password" in text
async def test_logout(client):
await client.post(
"/register",
data={
"full_name": "Test User",
"email": "test@example.com",
"password": "password",
"confirm_password": "password",
},
)
await client.post(
"/login", data={"email": "test@example.com", "password": "password"}
)
resp = await client.get("/logout", allow_redirects=False)
assert resp.status == 302
assert resp.headers["Location"] == "/"
+89
View File
@@ -0,0 +1,89 @@
async def test_index_get(client):
resp = await client.get("/")
assert resp.status == 200
text = await resp.text()
assert "Elevate Your Business Data" in text
assert "Start Free Trial" in text
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={
"full_name": "Test User",
"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()
assert "Your Data, Organized and Accessible" in text
assert "My Files" in text
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={
"full_name": "Test User",
"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={
"full_name": "Test User",
"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