Skip to content

Commit a3f0fd3

Browse files
committed
Use tornado.testing classes for tests, which use unittest
Rename test directories so the CI is not triggered by changes there
1 parent 01a119c commit a3f0fd3

File tree

5 files changed

+48
-32
lines changed

5 files changed

+48
-32
lines changed

testing.requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ pytest
22
pytest-asyncio
33
pytest-cov
44
pytest-mock
5-
pytest-tornado
File renamed without changes.
File renamed without changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import json
2+
import pathlib
3+
4+
import pytest
5+
from tornado.testing import AsyncHTTPTestCase
6+
7+
from srv.server import make_app
8+
9+
10+
@pytest.fixture(scope='function')
11+
def tmp_path_cls(request, tmp_path):
12+
request.cls.config_values = tmp_path
13+
14+
15+
@pytest.mark.usefixtures("tmp_path_cls")
16+
class TestKeyHandler(AsyncHTTPTestCase):
17+
config_values: pathlib.Path
18+
19+
def get_app(self):
20+
return make_app(self.config_values)
21+
22+
def test_root(self):
23+
response = self.fetch('/')
24+
self.assertEqual(response.code, 404)
25+
26+
def test_not_found(self):
27+
response = self.fetch('/key/not-found')
28+
self.assertEqual(response.code, 404)
29+
# self.assertEqual(response.body, 'Hello, world')
30+
31+
def test_key(self):
32+
test_file = self.config_values / "test"
33+
test_file.write_text(json.dumps({"foo": "bar"}))
34+
35+
response = self.fetch('/key/test')
36+
self.assertEqual(response.code, 200)
37+
self.assertEqual(response.body.decode(), json.dumps({"foo": "bar"}))
38+
39+
test_file.unlink()
40+
41+
def test_key_not_json(self):
42+
test_file = self.config_values / "test"
43+
test_file.write_text("something: not json")
44+
45+
response = self.fetch('/key/test')
46+
self.assertEqual(response.code, 400)
47+
48+
test_file.unlink()

tests/srv/test_key_handler.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)