From 6bc25d3d6e2dabbeeb0f02c37a0d2dee42739c49 Mon Sep 17 00:00:00 2001 From: Flavio Garcia Date: Fri, 29 Mar 2024 23:49:53 -0400 Subject: [PATCH] chore(transport): add get tornado request tests Refs: #6 --- tests/tornado_test.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/tornado_test.py b/tests/tornado_test.py index 0ca23f3..da15a3f 100644 --- a/tests/tornado_test.py +++ b/tests/tornado_test.py @@ -14,13 +14,40 @@ from firenado.testing import TornadoAsyncTestCase from firenado.launcher import ProcessLauncher -from peasant.client.transport_tornado import TornadoTransport +from peasant.client.transport import fix_address +from peasant.client.transport_tornado import (get_tornado_request, + TornadoTransport) from tests import chdir_fixture_app, PROJECT_ROOT from tornado.testing import gen_test +from unittest import TestCase + + +class GetTornadoRequestTestCase(TestCase): + + def test_get_tornado_request(self): + bastion_address = fix_address("http://bastion/") + request = get_tornado_request(bastion_address) + expected_url = "http://bastion" + self.assertEqual(expected_url, request.url) + + request = get_tornado_request(bastion_address, path="resource") + expected_url = "http://bastion/resource" + self.assertEqual(expected_url, request.url) + + request = get_tornado_request(bastion_address, path="/resource") + expected_url = "http://bastion/resource" + self.assertEqual(expected_url, request.url) + + request = get_tornado_request(bastion_address, path="resource/") + expected_url = "http://bastion/resource/" + self.assertEqual(expected_url, request.url) + + request = get_tornado_request(bastion_address, path="/resource/") + expected_url = "http://bastion/resource/" + self.assertEqual(expected_url, request.url) class TornadoTransportTestCase(TornadoAsyncTestCase): - """ Tornado based client test case. """ def get_launcher(self) -> ProcessLauncher: application_dir = chdir_fixture_app("bastiontest")