コミットメタ情報

リビジョンe11098cadf7e846bfd69c07568e1cd0a7f4eccb3 (tree)
日時2019-08-26 23:04:33
作者H. Turgut Uyar <uyar@teki...>
コミッターH. Turgut Uyar

ログメッセージ

Add web app skeleton

変更サマリ

差分

diff -r 71fddd277847 -r e11098cadf7e docs/source/modules/endpoints.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/modules/endpoints.rst Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,7 @@
1+:orphan:
2+
3+:mod:`humphrey.endpoints`
4+=========================
5+
6+.. automodule:: humphrey.endpoints
7+ :members:
diff -r 71fddd277847 -r e11098cadf7e docs/source/modules/server.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/source/modules/server.rst Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,7 @@
1+:orphan:
2+
3+:mod:`humphrey.server`
4+======================
5+
6+.. automodule:: humphrey.server
7+ :members:
diff -r 71fddd277847 -r e11098cadf7e humphrey/endpoints.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/humphrey/endpoints.py Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,27 @@
1+# Copyright (c) 2019 H. Turgut Uyar <uyar@tekir.org>
2+#
3+# This file is part of Humphrey.
4+#
5+# Humphrey is free software: you can redistribute it and/or modify
6+# it under the terms of the GNU General Public License as published by
7+# the Free Software Foundation, either version 3 of the License, or
8+# (at your option) any later version.
9+#
10+# Humphrey is distributed in the hope that it will be useful,
11+# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+# GNU General Public License for more details.
14+#
15+# You should have received a copy of the GNU General Public License
16+# along with Humphrey. If not, see <http://www.gnu.org/licenses/>.
17+
18+"""Handlers for incoming requests."""
19+
20+
21+def root():
22+ """Get the context for the root route.
23+
24+ :sig: () -> Dict
25+ :return: Root context.
26+ """
27+ return {}
diff -r 71fddd277847 -r e11098cadf7e humphrey/endpoints.pyi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/humphrey/endpoints.pyi Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,5 @@
1+# THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT MANUALLY.
2+
3+from typing import Dict
4+
5+def root() -> Dict: ...
diff -r 71fddd277847 -r e11098cadf7e humphrey/server.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/humphrey/server.py Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,42 @@
1+# Copyright (c) 2019 H. Turgut Uyar <uyar@tekir.org>
2+#
3+# This file is part of Humphrey.
4+#
5+# Humphrey is free software: you can redistribute it and/or modify
6+# it under the terms of the GNU General Public License as published by
7+# the Free Software Foundation, either version 3 of the License, or
8+# (at your option) any later version.
9+#
10+# Humphrey is distributed in the hope that it will be useful,
11+# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+# GNU General Public License for more details.
14+#
15+# You should have received a copy of the GNU General Public License
16+# along with Humphrey. If not, see <http://www.gnu.org/licenses/>.
17+
18+"""Web server components."""
19+
20+from clastic import Application
21+from clastic.render.chameleon_templates import ChameleonRenderFactory
22+from pathstring import Path
23+
24+from . import endpoints
25+
26+
27+TEMPLATES_PATH = Path(__file__).with_name("templates") # sig: str
28+
29+
30+def create_app():
31+ """Create a new application.
32+
33+ :sig: () -> Application
34+ :return: Created application.
35+ """
36+ ui_routes = [("/", endpoints.root, "index.pt")]
37+ ui_render_factory = ChameleonRenderFactory(TEMPLATES_PATH)
38+ ui_app = Application(ui_routes, render_factory=ui_render_factory)
39+
40+ routes = [("/", ui_app)]
41+ app = Application(routes)
42+ return app
diff -r 71fddd277847 -r e11098cadf7e humphrey/server.pyi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/humphrey/server.pyi Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,7 @@
1+# THIS FILE IS AUTOMATICALLY GENERATED, DO NOT EDIT MANUALLY.
2+
3+from clastic import Application
4+
5+TEMPLATES_PATH = ... # type: str
6+
7+def create_app() -> Application: ...
diff -r 71fddd277847 -r e11098cadf7e poetry.lock
--- a/poetry.lock Mon Aug 26 16:07:18 2019 +0300
+++ b/poetry.lock Mon Aug 26 17:04:33 2019 +0300
@@ -349,6 +349,14 @@
349349 six = "*"
350350
351351 [[package]]
352+category = "main"
353+description = "String with path operations."
354+name = "pathstring"
355+optional = false
356+python-versions = ">=3.5,<4.0"
357+version = "1.0.0"
358+
359+[[package]]
352360 category = "dev"
353361 description = "plugin and hook calling mechanisms for python"
354362 name = "pluggy"
@@ -731,7 +739,7 @@
731739 testing = ["pathlib2", "contextlib2", "unittest2"]
732740
733741 [metadata]
734-content-hash = "8671cd09879c93e0db6b5536502a9b41e793877f08e75e2de20b21b3c9d29dd9"
742+content-hash = "c07799bdb82fd3ad0b1945cad8bb3347d349336709379397ba1687d7ba991314"
735743 python-versions = "^3.5"
736744
737745 [metadata.hashes]
@@ -767,6 +775,7 @@
767775 more-itertools = ["409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832", "92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"]
768776 packaging = ["a7ac867b97fdc07ee80a8058fe4435ccd274ecc3b0ed61d852d7d53055528cf9", "c491ca87294da7cc01902edbe30a5bc6c4c28172b5138ab4e4aa1b9d7bfaeafe"]
769777 pathlib2 = ["2156525d6576d21c4dcaddfa427fae887ef89a7a9de5cbfe0728b3aafa78427e", "446014523bb9be5c28128c4d2a10ad6bb60769e78bd85658fe44a450674e0ef8"]
778+pathstring = ["8a89d029d8ccffb4a0c27d393ddae688ba2a5e88a1d5207c02f9902654c7e0d2", "98173829639fcb239ca4c2cc8078854a92c30c57d9307e0ad60fabebc689e11e"]
770779 pluggy = ["0825a152ac059776623854c1543d65a4ad408eb3d33ee114dff91e57ec6ae6fc", "b9817417e95936bf75d85d3f8767f7df6cdde751fc40aed3bb3074cbcb77757c"]
771780 py = ["64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", "dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"]
772781 pycodestyle = ["95a2219d12372f05704562a14ec30bc76b05a5b297b21a5dfe3f6fac3491ae56", "e40a936c9a450ad81df37f549d676d127b1b66000a6c500caa2b085bc0ca976c"]
diff -r 71fddd277847 -r e11098cadf7e pyproject.toml
--- a/pyproject.toml Mon Aug 26 16:07:18 2019 +0300
+++ b/pyproject.toml Mon Aug 26 17:04:33 2019 +0300
@@ -37,6 +37,7 @@
3737 python = "^3.5"
3838 clastic = {git = "https://github.com/mahmoud/clastic.git"}
3939 chameleon = "^3.6.2"
40+pathstring = "^1.0.0"
4041
4142 [tool.poetry.dev-dependencies]
4243 pytest = "^5.1.1"
diff -r 71fddd277847 -r e11098cadf7e setup.cfg
--- a/setup.cfg Mon Aug 26 16:07:18 2019 +0300
+++ b/setup.cfg Mon Aug 26 17:04:33 2019 +0300
@@ -5,5 +5,6 @@
55 line_length = 96
66 lines_after_imports = 2
77 known_first_party = humphrey
8-known_test = pytest
8+known_third_party = clastic
9+known_test = pytest,webtest
910 sections = TEST,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
diff -r 71fddd277847 -r e11098cadf7e tests/conftest.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/conftest.py Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,11 @@
1+from pytest import fixture
2+from webtest import TestApp
3+
4+from humphrey.server import create_app
5+
6+
7+@fixture(scope="session")
8+def humphrey():
9+ """A Humphrey application in a test environment."""
10+ app = create_app()
11+ yield TestApp(app)
diff -r 71fddd277847 -r e11098cadf7e tests/test_endpoints.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_endpoints.py Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,5 @@
1+from humphrey import endpoints
2+
3+
4+def test_root_context_should_be_empty():
5+ assert endpoints.root() == {}
diff -r 71fddd277847 -r e11098cadf7e tests/test_webapp.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_webapp.py Mon Aug 26 17:04:33 2019 +0300
@@ -0,0 +1,3 @@
1+def test_response_should_be_html(humphrey):
2+ response = humphrey.get("/")
3+ assert response.content_type == "text/html"
旧リポジトリブラウザで表示