style: format test files
This commit is contained in:
@@ -513,12 +513,12 @@ class TestConcurrentSubmissions:
|
|||||||
|
|
||||||
# First max_allowed should succeed
|
# First max_allowed should succeed
|
||||||
for i in range(max_allowed):
|
for i in range(max_allowed):
|
||||||
assert results[i][0] is True, f"Check {i+1} should be allowed"
|
assert results[i][0] is True, f"Check {i + 1} should be allowed"
|
||||||
assert results[i][1] == i + 1, f"Check {i+1} should have count {i+1}"
|
assert results[i][1] == i + 1, f"Check {i + 1} should have count {i + 1}"
|
||||||
|
|
||||||
# Rest should be denied
|
# Rest should be denied
|
||||||
for i in range(max_allowed, len(results)):
|
for i in range(max_allowed, len(results)):
|
||||||
assert results[i][0] is False, f"Check {i+1} should be denied"
|
assert results[i][0] is False, f"Check {i + 1} should be denied"
|
||||||
assert results[i][1] == max_allowed, f"Count should stay at {max_allowed}"
|
assert results[i][1] == max_allowed, f"Count should stay at {max_allowed}"
|
||||||
|
|
||||||
# Verify final database state
|
# Verify final database state
|
||||||
|
|||||||
@@ -164,9 +164,7 @@ def running_container(container_runtime, built_image):
|
|||||||
yield BASE_URL
|
yield BASE_URL
|
||||||
|
|
||||||
# Cleanup: stop and remove container
|
# Cleanup: stop and remove container
|
||||||
subprocess.run(
|
subprocess.run([container_runtime, "rm", "-f", CONTAINER_NAME], capture_output=True, timeout=30)
|
||||||
[container_runtime, "rm", "-f", CONTAINER_NAME], capture_output=True, timeout=30
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class TestContainerBuild:
|
class TestContainerBuild:
|
||||||
@@ -239,9 +237,7 @@ class TestContainerRuntime:
|
|||||||
paste_id = create_response.json()["id"]
|
paste_id = create_response.json()["id"]
|
||||||
|
|
||||||
# Retrieve
|
# Retrieve
|
||||||
get_response = requests.get(
|
get_response = requests.get(f"{running_container}/raw/{paste_id}", timeout=REQUEST_TIMEOUT)
|
||||||
f"{running_container}/raw/{paste_id}", timeout=REQUEST_TIMEOUT
|
|
||||||
)
|
|
||||||
assert get_response.status_code == 200
|
assert get_response.status_code == 200
|
||||||
assert get_response.content == content
|
assert get_response.content == content
|
||||||
|
|
||||||
@@ -257,9 +253,7 @@ class TestContainerRuntime:
|
|||||||
paste_id = create_response.json()["id"]
|
paste_id = create_response.json()["id"]
|
||||||
|
|
||||||
# Get info
|
# Get info
|
||||||
info_response = requests.get(
|
info_response = requests.get(f"{running_container}/{paste_id}", timeout=REQUEST_TIMEOUT)
|
||||||
f"{running_container}/{paste_id}", timeout=REQUEST_TIMEOUT
|
|
||||||
)
|
|
||||||
assert info_response.status_code == 200
|
assert info_response.status_code == 200
|
||||||
info = info_response.json()
|
info = info_response.json()
|
||||||
assert info["id"] == paste_id
|
assert info["id"] == paste_id
|
||||||
@@ -291,9 +285,7 @@ class TestContainerRuntime:
|
|||||||
|
|
||||||
def test_not_found_returns_json(self, running_container):
|
def test_not_found_returns_json(self, running_container):
|
||||||
"""404 errors should return JSON."""
|
"""404 errors should return JSON."""
|
||||||
response = requests.get(
|
response = requests.get(f"{running_container}/raw/nonexistent1234", timeout=REQUEST_TIMEOUT)
|
||||||
f"{running_container}/raw/nonexistent1234", timeout=REQUEST_TIMEOUT
|
|
||||||
)
|
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert "application/json" in response.headers.get("Content-Type", "")
|
assert "application/json" in response.headers.get("Content-Type", "")
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|||||||
@@ -150,9 +150,7 @@ class TestPastesList:
|
|||||||
assert data["count"] == 2
|
assert data["count"] == 2
|
||||||
assert data["offset"] == 2
|
assert data["offset"] == 2
|
||||||
|
|
||||||
def test_list_returns_metadata_only(
|
def test_list_returns_metadata_only(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
self, app: Flask, auth_client: FlaskClient
|
|
||||||
) -> None:
|
|
||||||
"""List should return metadata, not content."""
|
"""List should return metadata, not content."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
create_paste(auth_client, b"secret content", owner="a" * 40)
|
create_paste(auth_client, b"secret content", owner="a" * 40)
|
||||||
@@ -232,9 +230,7 @@ class TestPastesSearch:
|
|||||||
for paste in data["pastes"]:
|
for paste in data["pastes"]:
|
||||||
assert paste["created_at"] <= future
|
assert paste["created_at"] <= future
|
||||||
|
|
||||||
def test_search_combined_filters(
|
def test_search_combined_filters(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
self, app: Flask, auth_client: FlaskClient
|
|
||||||
) -> None:
|
|
||||||
"""Multiple filters can be combined."""
|
"""Multiple filters can be combined."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
create_paste(auth_client, b"test", owner="a" * 40)
|
create_paste(auth_client, b"test", owner="a" * 40)
|
||||||
@@ -262,9 +258,7 @@ class TestPasteUpdate:
|
|||||||
response = client.put(f"/{paste_id}", data=b"new content")
|
response = client.put(f"/{paste_id}", data=b"new content")
|
||||||
assert response.status_code == 401
|
assert response.status_code == 401
|
||||||
|
|
||||||
def test_update_requires_ownership(
|
def test_update_requires_ownership(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
self, app: Flask, auth_client: FlaskClient
|
|
||||||
) -> None:
|
|
||||||
"""Update requires paste ownership."""
|
"""Update requires paste ownership."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
# Create paste owned by different user
|
# Create paste owned by different user
|
||||||
@@ -312,9 +306,7 @@ class TestPasteUpdate:
|
|||||||
def test_update_password_remove(self, app: Flask, auth_client: FlaskClient) -> None:
|
def test_update_password_remove(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
"""Owner can remove password from paste."""
|
"""Owner can remove password from paste."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
paste_id = create_paste(
|
paste_id = create_paste(auth_client, b"content", owner="a" * 40, password="secret")
|
||||||
auth_client, b"content", owner="a" * 40, password="secret"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = auth_client.put(
|
response = auth_client.put(
|
||||||
f"/{paste_id}",
|
f"/{paste_id}",
|
||||||
@@ -331,9 +323,7 @@ class TestPasteUpdate:
|
|||||||
def test_update_extend_expiry(self, app: Flask, auth_client: FlaskClient) -> None:
|
def test_update_extend_expiry(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
"""Owner can extend paste expiry."""
|
"""Owner can extend paste expiry."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
paste_id = create_paste(
|
paste_id = create_paste(auth_client, b"content", owner="a" * 40, expires_in=3600)
|
||||||
auth_client, b"content", owner="a" * 40, expires_in=3600
|
|
||||||
)
|
|
||||||
# Get original expiry
|
# Get original expiry
|
||||||
info_response = auth_client.get(f"/{paste_id}")
|
info_response = auth_client.get(f"/{paste_id}")
|
||||||
original_expiry = info_response.get_json().get("expires_at")
|
original_expiry = info_response.get_json().get("expires_at")
|
||||||
@@ -362,14 +352,10 @@ class TestPasteUpdate:
|
|||||||
response = auth_client.put("/000000000000", data=b"content")
|
response = auth_client.put("/000000000000", data=b"content")
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
|
|
||||||
def test_update_burn_after_read_forbidden(
|
def test_update_burn_after_read_forbidden(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
self, app: Flask, auth_client: FlaskClient
|
|
||||||
) -> None:
|
|
||||||
"""Cannot update burn-after-read pastes."""
|
"""Cannot update burn-after-read pastes."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
paste_id = create_paste(
|
paste_id = create_paste(auth_client, b"content", owner="a" * 40, burn_after_read=True)
|
||||||
auth_client, b"content", owner="a" * 40, burn_after_read=True
|
|
||||||
)
|
|
||||||
|
|
||||||
response = auth_client.put(f"/{paste_id}", data=b"new content")
|
response = auth_client.put(f"/{paste_id}", data=b"new content")
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
@@ -405,9 +391,7 @@ class TestPasteDelete:
|
|||||||
get_response = auth_client.get(f"/{paste_id}")
|
get_response = auth_client.get(f"/{paste_id}")
|
||||||
assert get_response.status_code == 404
|
assert get_response.status_code == 404
|
||||||
|
|
||||||
def test_delete_requires_ownership(
|
def test_delete_requires_ownership(self, app: Flask, auth_client: FlaskClient) -> None:
|
||||||
self, app: Flask, auth_client: FlaskClient
|
|
||||||
) -> None:
|
|
||||||
"""Cannot delete paste owned by others."""
|
"""Cannot delete paste owned by others."""
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
paste_id = create_paste(auth_client, b"content", owner="c" * 40)
|
paste_id = create_paste(auth_client, b"content", owner="c" * 40)
|
||||||
|
|||||||
Reference in New Issue
Block a user