forked from tsileo/microblog.pub
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Running lint and fixed small test error on Python 3.10 * more linting * A lot more linting.
- Loading branch information
Showing
13 changed files
with
791 additions
and
738 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ __pycache__/ | |
docs/dist/ | ||
requirements.txt | ||
app/static/favicon.ico | ||
misc/dev-supervisord.conf |
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 |
---|---|---|
|
@@ -821,7 +821,7 @@ async def send_vote( | |
|
||
# commit db session | ||
await db_session.commit() | ||
|
||
return vote_id | ||
|
||
|
||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,34 @@ | ||
from fastapi.testclient import TestClient | ||
from unittest.mock import MagicMock | ||
|
||
from app.main import app | ||
from app.customization import get_custom_router, register_html_page, _CUSTOM_ROUTES | ||
from fastapi.testclient import TestClient | ||
|
||
from app.customization import _CUSTOM_ROUTES | ||
from app.customization import HTMLPage | ||
from app.customization import get_custom_router | ||
from app.customization import register_html_page | ||
from app.main import app | ||
|
||
|
||
def test_html_route(client: TestClient) -> None: | ||
test_path = "/test_registered_html" | ||
mock_file_contents = '<h1 class="test">This is test file content</h1>' | ||
|
||
# Test that we can register a HTML page | ||
register_html_page(test_path,title="my mock html page", html_file="test.txt",show_in_navbar=True) | ||
register_html_page( | ||
test_path, title="my mock html page", html_file="test.txt", show_in_navbar=True | ||
) | ||
|
||
# And that it gets added correctly as a route in the app | ||
app.include_router(get_custom_router()) | ||
custom_router = get_custom_router() | ||
assert custom_router is not None | ||
app.include_router(custom_router) | ||
assert test_path in _CUSTOM_ROUTES | ||
|
||
# confirm that the route also leads to the file being returned successfully. | ||
m = MagicMock(read_text=MagicMock(return_value=mock_file_contents)) | ||
_CUSTOM_ROUTES[test_path].html_file = m | ||
|
||
html_page = _CUSTOM_ROUTES[test_path] | ||
assert isinstance(html_page, HTMLPage) | ||
html_page.html_file = m | ||
response = client.get(test_path) | ||
assert response.status_code == 200 | ||
assert mock_file_contents in response.text | ||
|
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