-
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.
Refs: #5
- Loading branch information
Showing
7 changed files
with
160 additions
and
3 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
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,10 @@ | ||
from bastiontest import handlers | ||
from firenado import tornadoweb | ||
|
||
|
||
class BastiontestComponent(tornadoweb.TornadoComponent): | ||
|
||
def get_handlers(self): | ||
return [ | ||
(r"/", handlers.IndexHandler), | ||
] |
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,32 @@ | ||
app: | ||
component: 'bastiontest' | ||
pythonpath: ".." | ||
#type: 'tornado' | ||
port: 8888 | ||
|
||
data: | ||
sources: | ||
- name: session | ||
connector: redis | ||
# host: localhost | ||
# port: 6379 | ||
# db: 0 | ||
components: | ||
- id: bastiontest | ||
class: bastiontest.app.BastiontestComponent | ||
enabled: true | ||
#- id: admin | ||
# enabled: true | ||
#- id: info | ||
# enabled: true | ||
|
||
# Session types could be: | ||
# file or redis. | ||
session: | ||
type: redis | ||
enabled: false | ||
# Redis session handler configuration | ||
data: | ||
source: session | ||
# File session handler related configuration | ||
# path: /tmp |
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,7 @@ | ||
from firenado import tornadoweb | ||
|
||
|
||
class IndexHandler(tornadoweb.TornadoHandler): | ||
|
||
def get(self): | ||
self.write("IndexHandler output") |
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,33 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2020-2024 Flavio Garcia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# print current directory | ||
import unittest | ||
from tests import tornado_test | ||
|
||
|
||
def suite(): | ||
testLoader = unittest.TestLoader() | ||
alltests = unittest.TestSuite() | ||
alltests.addTests(testLoader.loadTestsFromModule(tornado_test)) | ||
return alltests | ||
|
||
|
||
if __name__ == "__main__": | ||
runner = unittest.TextTestRunner(verbosity=3) | ||
result = runner.run(suite()) | ||
if not result.wasSuccessful(): | ||
exit(2) |
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,38 @@ | ||
# Copyright 2020-2024 Flavio Garcia | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from firenado.testing import TornadoAsyncTestCase | ||
from firenado.launcher import ProcessLauncher | ||
from tests import chdir_fixture_app, PROJECT_ROOT | ||
from tornado.httpclient import AsyncHTTPClient | ||
from tornado.testing import gen_test | ||
|
||
|
||
class TornadoTransportTestCase(TornadoAsyncTestCase): | ||
""" Tornado based client test case. """ | ||
|
||
def get_launcher(self): | ||
application_dir = chdir_fixture_app("bastiontest") | ||
return ProcessLauncher( | ||
dir=application_dir, path=PROJECT_ROOT) | ||
|
||
@gen_test | ||
async def test_get(self): | ||
http_client = AsyncHTTPClient() | ||
try: | ||
response = await http_client.fetch( | ||
f"http://localhost:{self.http_port()}/") | ||
except Exception as e: | ||
raise e | ||
self.assertEqual(response.body, b"IndexHandler output") |