From e6d18b9205e1baf86df1e0cb3c5bf54c9489976f Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 29 Jun 2023 20:38:08 +0200 Subject: tileproxy: fix testing fake response --- fietsboek/views/tileproxy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fietsboek/views/tileproxy.py b/fietsboek/views/tileproxy.py index 07e4103..fe5cbae 100644 --- a/fietsboek/views/tileproxy.py +++ b/fietsboek/views/tileproxy.py @@ -334,8 +334,9 @@ def tile_proxy(request): 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") + if url.startswith("http://localhost:0"): + LOGGER.debug("Skipping tile proxy request for testing URL") + return Response(b"", content_type="image/png") headers = { "user-agent": f"Fietsboek-Tile-Proxy/{__VERSION__}", } -- cgit v1.2.3 From 2efc642f029fee9a5cf0640a766acd3cdf633eba Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 29 Jun 2023 20:38:30 +0200 Subject: tileproxy: use caplog in the test See if it works, it might be handy for other tests in the future as well. --- tests/conftest.py | 2 ++ tests/playwright/test_tileproxy.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index d4394cd..a4366ab 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,3 +1,4 @@ +import logging import os import shutil from pathlib import Path @@ -75,6 +76,7 @@ def _cleanup_data(app_settings): @pytest.fixture(scope='session') def app(app_settings, dbengine, tmp_path_factory): app_settings["fietsboek.data_dir"] = str(tmp_path_factory.mktemp("data")) + logging.getLogger().setLevel(logging.DEBUG) return main({}, dbengine=dbengine, **app_settings) @pytest.fixture diff --git a/tests/playwright/test_tileproxy.py b/tests/playwright/test_tileproxy.py index b948bab..bf1146b 100644 --- a/tests/playwright/test_tileproxy.py +++ b/tests/playwright/test_tileproxy.py @@ -1,7 +1,7 @@ from playwright.sync_api import Page -def test_tileproxy(page: Page, playwright_helper): +def test_tileproxy(page: Page, playwright_helper, caplog): playwright_helper.login() track_id = playwright_helper.add_track().id @@ -9,3 +9,5 @@ def test_tileproxy(page: Page, playwright_helper): with page.expect_request("/tile/test/**"): pass + + assert "Skipping tile proxy request for testing URL" in caplog.messages -- cgit v1.2.3 From ce6e8382b980b41eb9369f009ea492cafcf0437d Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 29 Jun 2023 20:51:15 +0200 Subject: install and run redis on CI --- .gitlab-ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8562f11..6ae2981 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" default: - image: python:latest + image: python:bullseye # Pip's cache doesn't store the python packages # https://pip.pypa.io/en/stable/topics/caching/ # @@ -24,6 +24,8 @@ test: - pip install poetry && pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ") - playwright install firefox - playwright install-deps + - apt install redis-server + - redis-server >/dev/null 2>&1 & - tox -e python -- --browser firefox test-pypy: @@ -36,6 +38,8 @@ test-pypy: - pip install poetry && pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ") - playwright install firefox - playwright install-deps + - apt install redis-server + - redis-server >/dev/null 2>&1 & - tox -e pypy3 -- --browser firefox lint: -- cgit v1.2.3 From 971fd5dd89e1cd26cfffdd5fdd68873dac90bc94 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Thu, 29 Jun 2023 20:59:56 +0200 Subject: actually confirm apt install --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6ae2981..e8971aa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,7 +24,7 @@ test: - pip install poetry && pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ") - playwright install firefox - playwright install-deps - - apt install redis-server + - apt install -y redis-server - redis-server >/dev/null 2>&1 & - tox -e python -- --browser firefox @@ -38,7 +38,7 @@ test-pypy: - pip install poetry && pip install "playwright=="$(poetry show playwright | grep version | cut -f 2 -d ":" | tr -d " ") - playwright install firefox - playwright install-deps - - apt install redis-server + - apt install -y redis-server - redis-server >/dev/null 2>&1 & - tox -e pypy3 -- --browser firefox -- cgit v1.2.3