Skip to content

Commit bd9a6c1

Browse files
Revert "ISSUE #92 - Remove unittest_run_loop"
This reverts commit 8ad997e
1 parent 8ad997e commit bd9a6c1

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

tests/test_api_gateway/test_rest/test_admin.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from aiohttp.test_utils import (
99
AioHTTPTestCase,
10+
unittest_run_loop,
1011
)
1112

1213
from minos.api_gateway.rest import (
@@ -42,6 +43,7 @@ async def get_application(self):
4243

4344
return await rest_service.create_application()
4445

46+
@unittest_run_loop
4547
async def test_admin_login(self):
4648
url = "/admin/login"
4749

@@ -55,6 +57,7 @@ async def test_admin_login(self):
5557
self.assertIn("id", await response.text())
5658
self.assertIn("token", await response.text())
5759

60+
@unittest_run_loop
5861
async def test_admin_login_no_data(self):
5962
url = "/admin/login"
6063

@@ -63,6 +66,7 @@ async def test_admin_login_no_data(self):
6366
self.assertEqual(401, response.status)
6467
self.assertDictEqual({"error": "Something went wrong!."}, json.loads(await response.text()))
6568

69+
@unittest_run_loop
6670
async def test_admin_login_wrong_data(self):
6771
url = "/admin/login"
6872

@@ -101,6 +105,7 @@ async def get_application(self):
101105

102106
return await rest_service.create_application()
103107

108+
@unittest_run_loop
104109
async def test_admin_get_endpoints(self):
105110
url = "/admin/endpoints"
106111

@@ -132,6 +137,7 @@ async def get_application(self):
132137

133138
return await rest_service.create_application()
134139

140+
@unittest_run_loop
135141
async def test_admin_get_endpoints(self):
136142
url = "/admin/endpoints"
137143

@@ -162,13 +168,15 @@ async def get_application(self):
162168

163169
return await rest_service.create_application()
164170

171+
@unittest_run_loop
165172
async def test_admin_get_rules(self):
166173
url = "/admin/rules"
167174

168175
response = await self.client.request("GET", url)
169176

170177
self.assertEqual(200, response.status)
171178

179+
@unittest_run_loop
172180
async def test_admin_create_rule(self):
173181
url = "/admin/rules"
174182

@@ -180,6 +188,7 @@ async def test_admin_create_rule(self):
180188

181189
self.assertEqual(200, response.status)
182190

191+
@unittest_run_loop
183192
async def test_admin_update_rule(self):
184193
url = "/admin/rules"
185194

@@ -203,6 +212,7 @@ async def test_admin_update_rule(self):
203212

204213
self.assertEqual(200, response.status)
205214

215+
@unittest_run_loop
206216
async def test_admin_delete_rule(self):
207217
url = "/admin/rules"
208218

tests/test_api_gateway/test_rest/test_authentication.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from aiohttp.test_utils import (
1212
AioHTTPTestCase,
13+
unittest_run_loop,
1314
)
1415
from werkzeug.exceptions import (
1516
abort,
@@ -87,6 +88,7 @@ async def get_application(self):
8788

8889
return await rest_service.create_application()
8990

91+
@unittest_run_loop
9092
async def test_auth_headers_1(self):
9193
url = "/order"
9294
headers = {"Authorization": "Bearer credential-token-test"}
@@ -96,6 +98,7 @@ async def test_auth_headers_1(self):
9698
self.assertEqual(200, response.status)
9799
self.assertIn("Microservice call correct!!!", await response.text())
98100

101+
@unittest_run_loop
99102
async def test_auth_headers_2(self):
100103
url = "/merchants/5"
101104
headers = {"Authorization": "Bearer credential-token-test"}
@@ -105,6 +108,7 @@ async def test_auth_headers_2(self):
105108
self.assertEqual(200, response.status)
106109
self.assertIn("Microservice call correct!!!", await response.text())
107110

111+
@unittest_run_loop
108112
async def test_auth_headers_3(self):
109113
url = "/categories/5"
110114
headers = {"Authorization": "Bearer credential-token-test"}
@@ -114,6 +118,7 @@ async def test_auth_headers_3(self):
114118
self.assertEqual(200, response.status)
115119
self.assertIn("Microservice call correct!!!", await response.text())
116120

121+
@unittest_run_loop
117122
async def test_default_auth_headers(self):
118123
url = "/auth/token"
119124
headers = {"Authorization": "Bearer credential-token-test"}
@@ -123,6 +128,7 @@ async def test_default_auth_headers(self):
123128
self.assertEqual(200, response.status)
124129
self.assertIn("token", await response.text())
125130

131+
@unittest_run_loop
126132
async def test_auth(self):
127133
url = "/auth/credentials"
128134
headers = {"Authorization": "Bearer credential-token-test"}
@@ -132,6 +138,7 @@ async def test_auth(self):
132138
self.assertEqual(200, response.status)
133139
self.assertIn("uuid", await response.text())
134140

141+
@unittest_run_loop
135142
async def test_wrong_auth_headers(self):
136143
url = "/order"
137144
headers = {"Authorization": "Bearer"} # Missing token
@@ -140,6 +147,7 @@ async def test_wrong_auth_headers(self):
140147
self.assertEqual(200, response.status)
141148
self.assertIn("Microservice call correct!!!", await response.text())
142149

150+
@unittest_run_loop
143151
async def test_request_has_token(self):
144152
url = "/order"
145153
headers = {"Authorization": "Bearer"} # Missing token
@@ -185,6 +193,7 @@ async def get_application(self):
185193

186194
return await rest_service.create_application()
187195

196+
@unittest_run_loop
188197
async def test_auth_disabled(self):
189198
url = "/order"
190199
headers = {"Authorization": "Bearer test_token"}
@@ -236,6 +245,7 @@ async def get_application(self):
236245

237246
return await rest_service.create_application()
238247

248+
@unittest_run_loop
239249
async def test_auth_unauthorized(self):
240250
await self.client.post(
241251
"/admin/rules",
@@ -286,6 +296,7 @@ async def get_application(self):
286296

287297
return await rest_service.create_application()
288298

299+
@unittest_run_loop
289300
async def test_auth_unreachable(self):
290301
url = "/merchants/iweuwieuwe"
291302
headers = {"Authorization": "Bearer test_token"}
@@ -294,6 +305,7 @@ async def test_auth_unreachable(self):
294305
self.assertEqual(503, response.status)
295306
self.assertEqual("The requested endpoint is not available.", await response.text())
296307

308+
@unittest_run_loop
297309
async def test_auth(self):
298310
url = "/auth/credentials"
299311
headers = {"Authorization": "Bearer credential-token-test"}

tests/test_api_gateway/test_rest/test_cors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import attr
77
from aiohttp.test_utils import (
88
AioHTTPTestCase,
9+
unittest_run_loop,
910
)
1011
from aiohttp_middlewares.cors import (
1112
ACCESS_CONTROL_ALLOW_HEADERS,
@@ -76,6 +77,7 @@ def check_allow_origin(
7677
if allow_methods:
7778
assert response.headers[ACCESS_CONTROL_ALLOW_METHODS] == ", ".join(allow_methods)
7879

80+
@unittest_run_loop
7981
async def test_cors_enabled(self):
8082
method = "GET"
8183
extra_headers = {}

tests/test_api_gateway/test_rest/test_service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from aiohttp.test_utils import (
77
AioHTTPTestCase,
8+
unittest_run_loop,
89
)
910
from werkzeug.exceptions import (
1011
abort,
@@ -59,34 +60,39 @@ async def get_application(self):
5960

6061
return await rest_service.create_application()
6162

63+
@unittest_run_loop
6264
async def test_get(self):
6365
url = "/order/5?verb=GET&path=12324"
6466
response = await self.client.request("GET", url)
6567

6668
self.assertEqual(200, response.status)
6769
self.assertIn("Microservice call correct!!!", await response.text())
6870

71+
@unittest_run_loop
6972
async def test_post(self):
7073
url = "/order"
7174
response = await self.client.request("POST", url)
7275

7376
self.assertEqual(200, response.status)
7477
self.assertIn("Microservice call correct!!!", await response.text())
7578

79+
@unittest_run_loop
7680
async def test_put(self):
7781
url = "/order/5"
7882
response = await self.client.request("PUT", url)
7983

8084
self.assertEqual(200, response.status)
8185
self.assertIn("Microservice call correct!!!", await response.text())
8286

87+
@unittest_run_loop
8388
async def test_patch(self):
8489
url = "/order/5"
8590
response = await self.client.request("PATCH", url)
8691

8792
self.assertEqual(200, response.status)
8893
self.assertIn("Microservice call correct!!!", await response.text())
8994

95+
@unittest_run_loop
9096
async def test_delete(self):
9197
url = "/order/5"
9298
response = await self.client.request("DELETE", url)
@@ -119,6 +125,7 @@ async def get_application(self):
119125

120126
return await rest_service.create_application()
121127

128+
@unittest_run_loop
122129
async def test_get(self):
123130
url = "/order/5?verb=GET&path=12324"
124131
response = await self.client.request("GET", url)
@@ -153,6 +160,7 @@ async def get_application(self):
153160

154161
return await rest_service.create_application()
155162

163+
@unittest_run_loop
156164
async def test_get(self):
157165
url = "/order/5?verb=GET&path=12324"
158166
response = await self.client.request("GET", url)
@@ -179,6 +187,7 @@ async def get_application(self):
179187

180188
return await rest_service.create_application()
181189

190+
@unittest_run_loop
182191
async def test_get(self):
183192
url = "/order/5?verb=GET&path=12324"
184193
response = await self.client.request("GET", url)
@@ -215,6 +224,7 @@ async def get_application(self):
215224

216225
return await rest_service.create_application()
217226

227+
@unittest_run_loop
218228
async def test_get(self):
219229
url = "/order/5?verb=GET&path=12324"
220230
response = await self.client.request("GET", url)

0 commit comments

Comments
 (0)