Skip to content

Commit dc58bcc

Browse files
committed
fixed failing test
1 parent b0404d5 commit dc58bcc

23 files changed

+88
-88
lines changed

ellar/core/routing/mount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
class EllarMount(StarletteMount):
2727
def __init__(
2828
self,
29-
*,
3029
path: str,
30+
*,
3131
routes: t.Optional[t.Sequence[t.Union[BaseRoute]]] = None,
3232
control_type: t.Optional[t.Type] = None,
3333
name: t.Optional[str] = None,

tests/test_application/test_app_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def add(a: Body[int], b: Body[int]):
8383
return a + b
8484

8585
app = tm.create_application()
86-
app.router.append(add)
86+
app.router.add_route(add)
8787

8888
async with app.application_context():
8989
res = tm.get_test_client().post("/", json={"a": 1, "b": 4})

tests/test_application/test_app_methods.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def homepage(request: Inject[Request], ctx: Inject[IExecutionContext]):
3434
await res(*ctx.get_args())
3535

3636
app = AppFactory.create_app()
37-
app.router.append(homepage)
37+
app.router.add_route(homepage)
3838
client = TestClient(app)
3939
response = client.get("/")
4040
assert response.status_code == 200
@@ -47,7 +47,7 @@ async def homepage(request: Inject[Request], ctx: Inject[IExecutionContext]):
4747
return res
4848

4949
app = AppFactory.create_app()
50-
app.router.append(homepage)
50+
app.router.add_route(homepage)
5151
result = app.url_path_for("homepage")
5252
assert result == "/homepage-url"
5353

@@ -156,7 +156,7 @@ async def catch(
156156
def raise_custom_exception():
157157
raise CustomException("Raised an Exception")
158158

159-
app.router.append(raise_custom_exception)
159+
app.router.add_route(raise_custom_exception)
160160
client = TestClient(app)
161161
res = client.get("/404")
162162
assert res.status_code == 404

tests/test_application/test_cors.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def homepage(request: Inject[Request]):
1818
}
1919
)
2020
app = tm.create_application()
21-
app.router.append(http_route(methods=["GET"])(homepage))
21+
app.router.add_route(http_route(methods=["GET"])(homepage))
2222
client = tm.get_test_client()
2323

2424
# Test pre-flight response
@@ -73,7 +73,7 @@ def homepage(request: Inject[Request]):
7373
}
7474
)
7575
app = tm.create_application()
76-
app.router.append(http_route(methods=["GET"])(homepage))
76+
app.router.add_route(http_route(methods=["GET"])(homepage))
7777

7878
client = tm.get_test_client()
7979

@@ -119,7 +119,7 @@ def homepage(request: Inject[Request]):
119119
}
120120
)
121121
app = tm.create_application()
122-
app.router.append(http_route(methods=["GET"])(homepage))
122+
app.router.add_route(http_route(methods=["GET"])(homepage))
123123

124124
client = tm.get_test_client()
125125

@@ -165,7 +165,7 @@ def homepage(request: Inject[Request]):
165165
)
166166
app = tm.create_application()
167167

168-
app.router.append(http_route(methods=["GET"])(homepage))
168+
app.router.add_route(http_route(methods=["GET"])(homepage))
169169
client = tm.get_test_client()
170170

171171
# Test pre-flight response
@@ -202,7 +202,7 @@ def homepage(request: Inject[Request]):
202202
}
203203
)
204204
app = tm.create_application()
205-
app.router.append(http_route(methods=["GET"])(homepage))
205+
app.router.add_route(http_route(methods=["GET"])(homepage))
206206

207207
client = tm.get_test_client()
208208

@@ -231,7 +231,7 @@ def homepage(request: Inject[Request]):
231231
)
232232
app = tm.create_application()
233233

234-
app.router.append(http_route(methods=["GET"])(homepage))
234+
app.router.add_route(http_route(methods=["GET"])(homepage))
235235
client = tm.get_test_client()
236236

237237
headers = {
@@ -254,7 +254,7 @@ def homepage(request: Inject[Request]):
254254
config_module={"CORS_ALLOW_ORIGINS": ["*"], "CORS_ALLOW_METHODS": ["*"]}
255255
)
256256
app = tm.create_application()
257-
app.router.append(http_route(methods=methods)(homepage))
257+
app.router.add_route(http_route(methods=methods)(homepage))
258258
client = tm.get_test_client()
259259

260260
headers = {"Origin": "https://example.org"}
@@ -279,7 +279,7 @@ def homepage(request: Inject[Request]):
279279
}
280280
)
281281
app = tm.create_application()
282-
app.router.append(http_route(methods=["GET"])(homepage))
282+
app.router.add_route(http_route(methods=["GET"])(homepage))
283283

284284
client = tm.get_test_client()
285285

@@ -346,7 +346,7 @@ def homepage(request: Inject[Request]):
346346
}
347347
)
348348
app = tm.create_application()
349-
app.router.append(http_route(methods=["GET"])(homepage))
349+
app.router.add_route(http_route(methods=["GET"])(homepage))
350350

351351
client = tm.get_test_client()
352352

@@ -375,7 +375,7 @@ def homepage(request: Inject[Request]):
375375

376376
tm = Test.create_test_module(config_module={"CORS_ALLOW_ORIGINS": ["*"]})
377377
app = tm.create_application()
378-
app.router.append(http_route(methods=["GET"])(homepage))
378+
app.router.add_route(http_route(methods=["GET"])(homepage))
379379
client = tm.get_test_client()
380380

381381
# Test credentialed request
@@ -395,7 +395,7 @@ def homepage(request: Inject[Request]):
395395
config_module={"CORS_ALLOW_ORIGINS": ["https://example.org"]}
396396
)
397397
app = tm.create_application()
398-
app.router.append(http_route(methods=["GET"])(homepage))
398+
app.router.add_route(http_route(methods=["GET"])(homepage))
399399

400400
client = tm.get_test_client()
401401

@@ -414,7 +414,7 @@ def homepage(request: Inject[Request]):
414414

415415
tm = Test.create_test_module(config_module={"CORS_ALLOW_ORIGINS": ["*"]})
416416
app = tm.create_application()
417-
app.router.append(http_route(methods=["GET"])(homepage))
417+
app.router.add_route(http_route(methods=["GET"])(homepage))
418418

419419
client = tm.get_test_client()
420420

@@ -431,7 +431,7 @@ def homepage(request: Inject[Request]):
431431

432432
tm = Test.create_test_module(config_module={"CORS_ALLOW_ORIGINS": ["*"]})
433433
app = tm.create_application()
434-
app.router.append(http_route(methods=["GET"])(homepage))
434+
app.router.add_route(http_route(methods=["GET"])(homepage))
435435
client = tm.get_test_client()
436436

437437
response = client.get(
@@ -451,7 +451,7 @@ def homepage(request: Inject[Request]):
451451
config_module={"CORS_ALLOW_ORIGINS": ["https://example.org"]}
452452
)
453453
app = tm.create_application()
454-
app.router.append(http_route(methods=["GET"])(homepage))
454+
app.router.add_route(http_route(methods=["GET"])(homepage))
455455

456456
client = tm.get_test_client()
457457

@@ -472,7 +472,7 @@ def homepage(request: Inject[Request]):
472472
}
473473
)
474474
app = tm.create_application()
475-
app.router.append(http_route(methods=["GET"])(homepage))
475+
app.router.add_route(http_route(methods=["GET"])(homepage))
476476
client = tm.get_test_client()
477477

478478
response = client.get("/", headers={"Origin": "https://someplace.org"})

tests/test_application/test_starlette_compatibility.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def homepage(request: Inject[Request]):
123123
raise RuntimeError()
124124

125125
app = AppFactory.create_app()
126-
app.router.append(homepage)
126+
app.router.add_route(homepage)
127127
app.debug = True
128128

129129
client = TestClient(app, raise_server_exceptions=False)
@@ -139,7 +139,7 @@ async def homepage(request: Inject[Request]):
139139
raise RuntimeError()
140140

141141
app = AppFactory.create_app()
142-
app.router.append(homepage)
142+
app.router.add_route(homepage)
143143
app.debug = True
144144

145145
client = TestClient(app, raise_server_exceptions=False)

tests/test_application/test_trusted_host.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def homepage(request: Inject[Request]):
1313
config_module={"ALLOWED_HOSTS": ["testserver", "*.testserver"]}
1414
)
1515
app = tm.create_application()
16-
app.router.append(homepage)
16+
app.router.add_route(homepage)
1717

1818
assert app.debug is False
1919

@@ -40,7 +40,7 @@ def homepage(request: Inject[Request]):
4040
config_module={"ALLOWED_HOSTS": ["testserver", "*.testserver"]}
4141
)
4242
app = tm.create_application()
43-
app.router.append(homepage)
43+
app.router.add_route(homepage)
4444

4545
assert app.debug is False
4646
app.debug = True
@@ -71,7 +71,7 @@ def homepage(request: Inject[Request]):
7171

7272
tm = Test.create_test_module(config_module={"ALLOWED_HOSTS": ["www.example.com"]})
7373
app = tm.create_application()
74-
app.router.append(homepage)
74+
app.router.add_route(homepage)
7575

7676
client = tm.get_test_client(base_url="https://example.com")
7777
response = client.get("/")

tests/test_auth/test_guards/test_auth_guards.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def authentication_handler(self, context, credentials):
117117
def auth_demo_endpoint(request: Inject[Request]):
118118
return {"authentication": request.user}
119119

120-
app.router.append(auth_demo_endpoint)
120+
app.router.add_route(auth_demo_endpoint)
121121

122122
client = TestClient(app)
123123

@@ -273,7 +273,7 @@ def test_global_guard_case_1_works():
273273
def _auth_demo_endpoint(request: Inject[Request]):
274274
return {"authentication": request.user}
275275

276-
_app.router.append(_auth_demo_endpoint)
276+
_app.router.add_route(_auth_demo_endpoint)
277277
_client = TestClient(_app)
278278
res = _client.get("/global")
279279

@@ -292,7 +292,7 @@ def test_global_guard_case_2_works():
292292
def _auth_demo_endpoint(request: Request):
293293
return {"authentication": request.user}
294294

295-
_app.router.append(_auth_demo_endpoint)
295+
_app.router.add_route(_auth_demo_endpoint)
296296
_client = TestClient(_app)
297297
res = _client.get("/global")
298298

@@ -332,7 +332,7 @@ def _auth_demo_endpoint(request: Request):
332332
assert request.user.is_authenticated == is_authenticated
333333
return {"authentication": request.user}
334334

335-
_app.router.append(_auth_demo_endpoint)
335+
_app.router.add_route(_auth_demo_endpoint)
336336
_client = TestClient(_app)
337337
res = _client.get(
338338
"/global",

tests/test_auth/test_session/test_session_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def homepage(req: Inject[Request]):
1212

1313

1414
tm = Test.create_test_module()
15-
tm.create_application().router.append(homepage)
15+
tm.create_application().router.add_route(homepage)
1616

1717

1818
def test_session_object_raise_an_exception():
@@ -27,7 +27,7 @@ def test_session_object_raise_an_exception():
2727
def test_session_object_raise_an_exception_case_2():
2828
tm_case_2 = Test.create_test_module(config_module={"SESSION_DISABLED": True})
2929
tm_case_2.override_provider(SessionStrategy, use_class=SessionClientStrategy)
30-
tm_case_2.create_application().router.append(homepage)
30+
tm_case_2.create_application().router.add_route(homepage)
3131
session_service = tm_case_2.get(SessionStrategy)
3232
assert isinstance(session_service, SessionClientStrategy)
3333

tests/test_exceptions/test_api_exception.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def exception_():
2727
_exception_runner.run()
2828

2929

30-
test_module.create_application().router.append(exception_)
30+
test_module.create_application().router.add_route(exception_)
3131
client = test_module.get_test_client()
3232

3333

tests/test_exceptions/test_custom_exceptions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def homepage():
133133

134134
tm = Test.create_test_module()
135135
app = tm.create_application()
136-
app.router.append(homepage)
136+
app.router.add_route(homepage)
137137
app.add_exception_handler(NewExceptionHandler())
138138

139139
client = tm.get_test_client()
@@ -149,7 +149,7 @@ def homepage():
149149

150150
tm = Test.create_test_module()
151151
app = tm.create_application()
152-
app.router.append(homepage)
152+
app.router.add_route(homepage)
153153
app.add_exception_handler(OverrideAPIExceptionHandler())
154154

155155
client = tm.get_test_client()
@@ -175,7 +175,7 @@ def homepage():
175175
tm = Test.create_test_module()
176176
app = tm.create_application()
177177

178-
app.router.append(homepage)
178+
app.router.add_route(homepage)
179179
app.add_exception_handler(exception_handler)
180180

181181
client = tm.get_test_client(raise_server_exceptions=False)
@@ -192,7 +192,7 @@ def homepage():
192192
tm = Test.create_test_module()
193193
app = tm.create_application()
194194

195-
app.router.append(homepage)
195+
app.router.add_route(homepage)
196196
client = tm.get_test_client()
197197
res = client.get("/")
198198
assert res.status_code == 400
@@ -208,7 +208,7 @@ def homepage():
208208
tm = Test.create_test_module()
209209
app = tm.create_application()
210210

211-
app.router.append(homepage)
211+
app.router.add_route(homepage)
212212

213213
client = tm.get_test_client()
214214
res = client.get("/")
@@ -240,7 +240,7 @@ def homepage():
240240
tm = Test.create_test_module()
241241
app = tm.create_application()
242242

243-
app.router.append(homepage)
243+
app.router.add_route(homepage)
244244
app.add_exception_handler(OverrideHTTPException())
245245

246246
client = tm.get_test_client()
@@ -258,7 +258,7 @@ def homepage():
258258
tm = Test.create_test_module()
259259
app = tm.create_application()
260260

261-
app.router.append(homepage)
261+
app.router.add_route(homepage)
262262
app.add_exception_handler(RuntimeHTTPException())
263263
with pytest.raises(
264264
RuntimeError, match="HTTP ExceptionHandler must return a response."
@@ -310,8 +310,8 @@ def homepage_2():
310310
tm = Test.create_test_module()
311311
app = tm.create_application()
312312

313-
app.router.append(homepage)
314-
app.router.append(homepage_2)
313+
app.router.add_route(homepage)
314+
app.router.add_route(homepage_2)
315315
client = tm.get_test_client()
316316

317317
res = client.get("/case_1")
@@ -337,7 +337,7 @@ async def homepage_3(session: Inject[WebSocket]):
337337
tm = Test.create_test_module()
338338
app = tm.create_application()
339339

340-
app.router.append(homepage_3)
340+
app.router.add_route(homepage_3)
341341
client = tm.get_test_client()
342342

343343
with client.websocket_connect("/ws"):

0 commit comments

Comments
 (0)