-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
130 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
aiofiles==23.2.1 | ||
fastapi==0.110.0 | ||
httpx==0.26.0 | ||
Jinja2==3.1.3 | ||
Markdown==3.6 | ||
nh3==0.2.17 | ||
pydantic==2.6.4 | ||
pytest==8.1.1 | ||
python-multipart==0.0.9 | ||
uvicorn==0.29.0 | ||
weasyprint==61.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,37 @@ | ||
import copy | ||
import json | ||
from fastapi.testclient import TestClient | ||
|
||
from muckraker.main import app | ||
|
||
# Is it a good idea to set headers manually? | ||
FORM_HEADERS = {'Content-Type': 'application/x-www-form-urlencoded'} | ||
|
||
client = TestClient(app) | ||
|
||
|
||
def test_issue_thick_body(issue): | ||
issue["body"] = issue["body"] * 100 | ||
resp = client.post("/issue/", json=issue) | ||
assert resp.status_code == 422 | ||
def test_issue_correct(issue_dict): | ||
content = "issue=" + json.dumps(issue_dict) | ||
resp = client.post( | ||
"/issue/", | ||
content=content, | ||
headers=FORM_HEADERS | ||
) | ||
assert resp.status_code == 200 | ||
|
||
|
||
def test_issue_thick_heading(issue): | ||
for field in issue["config"]["heading"]: | ||
print(field) | ||
new_issue = copy.copy(issue) | ||
new_issue["config"]["heading"][field] = "a" * 1000 | ||
resp = client.post("/issue/", json=new_issue) | ||
assert resp.status_code == 422 | ||
def test_issue_thick_body(issue_dict): | ||
issue_dict["body"] = issue_dict["body"] * 100 | ||
content = "issue=" + json.dumps(issue_dict) | ||
resp = client.post("/issue/", content=content, headers=FORM_HEADERS) | ||
assert resp.status_code == 422 | ||
|
||
|
||
def test_issue_correct(issue): | ||
resp = client.post("/issue/", json=issue) | ||
assert resp.status_code == 200 | ||
def test_issue_thick_heading(issue_dict): | ||
any_field = list(issue_dict["heading"].keys())[0] | ||
issue_dict["heading"][any_field] = "a" * 100 | ||
content = "issue=" + json.dumps(issue_dict) | ||
resp = client.post("/issue/", content=content, headers=FORM_HEADERS) | ||
assert resp.status_code == 422 | ||
detail = resp.json()["detail"][0] | ||
assert detail["type"] == "string_too_long" | ||
assert detail["loc"] == ["body", "issue", "heading", any_field] |