From 99e3e33cf0a529fa3fe71af98ce5017054dbb8ea Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 22 Jun 2023 22:29:14 +0200 Subject: add preliminary tileproxy test --- fietsboek/views/tileproxy.py | 3 +++ testing.ini | 3 +++ tests/playwright/test_tileproxy.py | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 tests/playwright/test_tileproxy.py diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py index d3216c4..07e4103 100644 --- a/fietsboek/views/tileproxy.py +++ b/fietsboek/views/tileproxy.py @@ -333,6 +333,9 @@ def tile_proxy(request): raise HTTPGatewayTimeout(f"Avoiding request to {provider}") url = tile_sources[provider].url.format(x=x, y=y, z=z, s=random.choice("abc")) + # Avoid doing actual requests during tests + if url.startswith("http://localhost:0/"): + return Response("", content_type="image/png") headers = { "user-agent": f"Fietsboek-Tile-Proxy/{__VERSION__}", } diff --git a/testing.ini b/testing.ini index e68d0cc..6f85219 100644 --- a/testing.ini +++ b/testing.ini @@ -18,6 +18,9 @@ redis.url = redis://localhost fietsboek.default_tile_layers = enable_account_registration = true +fietsboek.tile_layer.test = Testing Tile Layer +fietsboek.tile_layer.test.url = http://localhost:0 + email.from = Test email.smtp_url = debug:// diff --git a/tests/playwright/test_tileproxy.py b/tests/playwright/test_tileproxy.py new file mode 100644 index 0000000..b948bab --- /dev/null +++ b/tests/playwright/test_tileproxy.py @@ -0,0 +1,11 @@ +from playwright.sync_api import Page + + +def test_tileproxy(page: Page, playwright_helper): + playwright_helper.login() + track_id = playwright_helper.add_track().id + + page.goto(f"/track/{track_id}") + + with page.expect_request("/tile/test/**"): + pass -- cgit v1.2.3