From bd9a6c1bb8ca01af6e67a4c73ce71e7ef39606a0 Mon Sep 17 00:00:00 2001 From: Vladyslav Fenchak Date: Wed, 16 Feb 2022 12:51:55 +0100 Subject: [PATCH] Revert "ISSUE #92 - Remove unittest_run_loop" This reverts commit 8ad997ee --- tests/test_api_gateway/test_rest/test_admin.py | 10 ++++++++++ .../test_rest/test_authentication.py | 12 ++++++++++++ tests/test_api_gateway/test_rest/test_cors.py | 2 ++ tests/test_api_gateway/test_rest/test_service.py | 10 ++++++++++ 4 files changed, 34 insertions(+) diff --git a/tests/test_api_gateway/test_rest/test_admin.py b/tests/test_api_gateway/test_rest/test_admin.py index 17a33c2..c8d97a8 100644 --- a/tests/test_api_gateway/test_rest/test_admin.py +++ b/tests/test_api_gateway/test_rest/test_admin.py @@ -7,6 +7,7 @@ from aiohttp.test_utils import ( AioHTTPTestCase, + unittest_run_loop, ) from minos.api_gateway.rest import ( @@ -42,6 +43,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_admin_login(self): url = "/admin/login" @@ -55,6 +57,7 @@ async def test_admin_login(self): self.assertIn("id", await response.text()) self.assertIn("token", await response.text()) + @unittest_run_loop async def test_admin_login_no_data(self): url = "/admin/login" @@ -63,6 +66,7 @@ async def test_admin_login_no_data(self): self.assertEqual(401, response.status) self.assertDictEqual({"error": "Something went wrong!."}, json.loads(await response.text())) + @unittest_run_loop async def test_admin_login_wrong_data(self): url = "/admin/login" @@ -101,6 +105,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_admin_get_endpoints(self): url = "/admin/endpoints" @@ -132,6 +137,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_admin_get_endpoints(self): url = "/admin/endpoints" @@ -162,6 +168,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_admin_get_rules(self): url = "/admin/rules" @@ -169,6 +176,7 @@ async def test_admin_get_rules(self): self.assertEqual(200, response.status) + @unittest_run_loop async def test_admin_create_rule(self): url = "/admin/rules" @@ -180,6 +188,7 @@ async def test_admin_create_rule(self): self.assertEqual(200, response.status) + @unittest_run_loop async def test_admin_update_rule(self): url = "/admin/rules" @@ -203,6 +212,7 @@ async def test_admin_update_rule(self): self.assertEqual(200, response.status) + @unittest_run_loop async def test_admin_delete_rule(self): url = "/admin/rules" diff --git a/tests/test_api_gateway/test_rest/test_authentication.py b/tests/test_api_gateway/test_rest/test_authentication.py index 601ef96..ae06c55 100644 --- a/tests/test_api_gateway/test_rest/test_authentication.py +++ b/tests/test_api_gateway/test_rest/test_authentication.py @@ -10,6 +10,7 @@ from aiohttp.test_utils import ( AioHTTPTestCase, + unittest_run_loop, ) from werkzeug.exceptions import ( abort, @@ -87,6 +88,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_auth_headers_1(self): url = "/order" headers = {"Authorization": "Bearer credential-token-test"} @@ -96,6 +98,7 @@ async def test_auth_headers_1(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_auth_headers_2(self): url = "/merchants/5" headers = {"Authorization": "Bearer credential-token-test"} @@ -105,6 +108,7 @@ async def test_auth_headers_2(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_auth_headers_3(self): url = "/categories/5" headers = {"Authorization": "Bearer credential-token-test"} @@ -114,6 +118,7 @@ async def test_auth_headers_3(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_default_auth_headers(self): url = "/auth/token" headers = {"Authorization": "Bearer credential-token-test"} @@ -123,6 +128,7 @@ async def test_default_auth_headers(self): self.assertEqual(200, response.status) self.assertIn("token", await response.text()) + @unittest_run_loop async def test_auth(self): url = "/auth/credentials" headers = {"Authorization": "Bearer credential-token-test"} @@ -132,6 +138,7 @@ async def test_auth(self): self.assertEqual(200, response.status) self.assertIn("uuid", await response.text()) + @unittest_run_loop async def test_wrong_auth_headers(self): url = "/order" headers = {"Authorization": "Bearer"} # Missing token @@ -140,6 +147,7 @@ async def test_wrong_auth_headers(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_request_has_token(self): url = "/order" headers = {"Authorization": "Bearer"} # Missing token @@ -185,6 +193,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_auth_disabled(self): url = "/order" headers = {"Authorization": "Bearer test_token"} @@ -236,6 +245,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_auth_unauthorized(self): await self.client.post( "/admin/rules", @@ -286,6 +296,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_auth_unreachable(self): url = "/merchants/iweuwieuwe" headers = {"Authorization": "Bearer test_token"} @@ -294,6 +305,7 @@ async def test_auth_unreachable(self): self.assertEqual(503, response.status) self.assertEqual("The requested endpoint is not available.", await response.text()) + @unittest_run_loop async def test_auth(self): url = "/auth/credentials" headers = {"Authorization": "Bearer credential-token-test"} diff --git a/tests/test_api_gateway/test_rest/test_cors.py b/tests/test_api_gateway/test_rest/test_cors.py index 31264f2..7072927 100644 --- a/tests/test_api_gateway/test_rest/test_cors.py +++ b/tests/test_api_gateway/test_rest/test_cors.py @@ -6,6 +6,7 @@ import attr from aiohttp.test_utils import ( AioHTTPTestCase, + unittest_run_loop, ) from aiohttp_middlewares.cors import ( ACCESS_CONTROL_ALLOW_HEADERS, @@ -76,6 +77,7 @@ def check_allow_origin( if allow_methods: assert response.headers[ACCESS_CONTROL_ALLOW_METHODS] == ", ".join(allow_methods) + @unittest_run_loop async def test_cors_enabled(self): method = "GET" extra_headers = {} diff --git a/tests/test_api_gateway/test_rest/test_service.py b/tests/test_api_gateway/test_rest/test_service.py index 32628f8..49f383c 100644 --- a/tests/test_api_gateway/test_rest/test_service.py +++ b/tests/test_api_gateway/test_rest/test_service.py @@ -5,6 +5,7 @@ from aiohttp.test_utils import ( AioHTTPTestCase, + unittest_run_loop, ) from werkzeug.exceptions import ( abort, @@ -59,6 +60,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_get(self): url = "/order/5?verb=GET&path=12324" response = await self.client.request("GET", url) @@ -66,6 +68,7 @@ async def test_get(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_post(self): url = "/order" response = await self.client.request("POST", url) @@ -73,6 +76,7 @@ async def test_post(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_put(self): url = "/order/5" response = await self.client.request("PUT", url) @@ -80,6 +84,7 @@ async def test_put(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_patch(self): url = "/order/5" response = await self.client.request("PATCH", url) @@ -87,6 +92,7 @@ async def test_patch(self): self.assertEqual(200, response.status) self.assertIn("Microservice call correct!!!", await response.text()) + @unittest_run_loop async def test_delete(self): url = "/order/5" response = await self.client.request("DELETE", url) @@ -119,6 +125,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_get(self): url = "/order/5?verb=GET&path=12324" response = await self.client.request("GET", url) @@ -153,6 +160,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_get(self): url = "/order/5?verb=GET&path=12324" response = await self.client.request("GET", url) @@ -179,6 +187,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_get(self): url = "/order/5?verb=GET&path=12324" response = await self.client.request("GET", url) @@ -215,6 +224,7 @@ async def get_application(self): return await rest_service.create_application() + @unittest_run_loop async def test_get(self): url = "/order/5?verb=GET&path=12324" response = await self.client.request("GET", url)