-
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.
Rename packages to 'opr' because 'operator' is a package in the pytho…
…n standard library and imports fail otherwise Rename 'server' to 'srv' for consistency Add pytest tests for tornado
- Loading branch information
Showing
18 changed files
with
44 additions
and
7 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
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,5 @@ | ||
pytest | ||
pytest-asyncio | ||
pytest-cov | ||
pytest-mock | ||
pytest-tornado |
Empty file.
Empty file.
Empty file.
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,31 @@ | ||
import json | ||
import os.path | ||
import pathlib | ||
|
||
from tornado.httpclient import HTTPClientError | ||
|
||
import pytest | ||
|
||
from srv.server import make_app | ||
|
||
|
||
@pytest.fixture | ||
def app(tmp_path): | ||
return make_app(tmp_path) | ||
|
||
|
||
@pytest.mark.gen_test | ||
async def test_key_not_found(http_client, base_url): | ||
with pytest.raises(HTTPClientError) as e: | ||
await http_client.fetch(os.path.join(base_url, "key", "non_existent")) | ||
assert e.value.code == 404 | ||
|
||
|
||
@pytest.mark.gen_test | ||
async def test_key_not_found(http_client, base_url, app): | ||
path: pathlib.Path = app.settings["config_values"] | ||
test_file = path / "test" | ||
test_file.write_text(json.dumps({"foo": "bar"})) | ||
response = await http_client.fetch(os.path.join(base_url, "key", "test")) | ||
assert response.code == 200 | ||
assert response.body.decode() == json.dumps({"foo": "bar"}) |