-
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.
Refactor tests and run linting on tests
- Loading branch information
Showing
11 changed files
with
379 additions
and
489 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from collections.abc import Generator | ||
|
||
from click.testing import CliRunner | ||
from htmd.cli import start | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='function') # noqa: PT003 | ||
def run_start() -> Generator[CliRunner, None, None]: | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
result = runner.invoke(start) | ||
assert result.exit_code == 0 | ||
# Tests code is run here | ||
yield runner |
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,41 +1,45 @@ | ||
from collections.abc import Generator | ||
|
||
from click.testing import CliRunner | ||
from flask import Flask | ||
from flask.testing import FlaskClient | ||
from htmd.cli import start | ||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def run_start(): | ||
def run_start() -> Generator[CliRunner, None, None]: | ||
runner = CliRunner() | ||
with runner.isolated_filesystem(): | ||
result = runner.invoke(start) | ||
assert result.exit_code == 0 | ||
# Tests code is run here | ||
yield | ||
yield runner | ||
|
||
|
||
@pytest.fixture() | ||
def flask_app(run_start): | ||
def flask_app(run_start: CliRunner) -> Flask: | ||
from htmd.site import app | ||
app.config.update({ | ||
'TESTING': True, | ||
}) | ||
yield app | ||
return app | ||
|
||
|
||
@pytest.fixture() | ||
def client(flask_app): | ||
def client(flask_app: Flask) -> FlaskClient: | ||
return flask_app.test_client() | ||
|
||
|
||
def test_author_does_not_exist(client) -> None: | ||
def test_author_does_not_exist(client: FlaskClient) -> None: | ||
# If the author doesn't exist it will be a 404 | ||
response = client.get("/author/dne/") | ||
assert 404 == response.status_code | ||
response = client.get('/author/dne/') | ||
assert response.status_code == 404 # noqa: PLR2004 | ||
|
||
|
||
def test_page_does_not_exist(client) -> None: | ||
def test_page_does_not_exist(client: FlaskClient) -> None: | ||
# Ensure htmd preview matches build | ||
# Only pages will be served | ||
# before this change pages.page was serving templates | ||
response = client.get("/author/") | ||
assert 404 == response.status_code | ||
response = client.get('/author/') | ||
assert response.status_code == 404 # noqa: PLR2004 |
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
Oops, something went wrong.