From 3a5174c0038b22d3f9d0f886efd172292799fa27 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 4 Sep 2023 15:04:00 +0200 Subject: [PATCH] Fix tests with playwright Basically: - when using playwright, we use live_server - live_server make django-pytest switch in "transactional db" mode - when in this mode, it will reset all data of all tables in db - we relied on data created during the migrations, so only available for first test run --- umap/tests/conftest.py | 14 +++++++++----- umap/tests/integration/test_basics.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/umap/tests/conftest.py b/umap/tests/conftest.py index 0f3bd6ce..a9a29726 100644 --- a/umap/tests/conftest.py +++ b/umap/tests/conftest.py @@ -5,8 +5,13 @@ import pytest from django.core.cache import cache from django.core.signing import get_cookie_signer -from .base import DataLayerFactory, MapFactory, UserFactory -from umap.models import Licence, TileLayer +from .base import ( + DataLayerFactory, + MapFactory, + UserFactory, + TileLayerFactory, + LicenceFactory, +) TMP_ROOT = tempfile.mkdtemp() @@ -37,8 +42,7 @@ def user2(): @pytest.fixture def licence(): - # Should be created by the migrations. - return Licence.objects.last() + return LicenceFactory() @pytest.fixture @@ -73,4 +77,4 @@ def datalayer(map): @pytest.fixture def tilelayer(): - return TileLayer.objects.last() + return TileLayerFactory() diff --git a/umap/tests/integration/test_basics.py b/umap/tests/integration/test_basics.py index 9f9e6755..206cc785 100644 --- a/umap/tests/integration/test_basics.py +++ b/umap/tests/integration/test_basics.py @@ -18,7 +18,7 @@ def test_create_map_link(page, live_server, lang, link_name, link_url): expect(create_map_button).to_have_attribute("href", link_url) -def test_create_map_with_cursor(page, live_server): +def test_create_map_with_cursor(page, live_server, tilelayer): page.goto(f"{live_server.url}/en/map/new/") # Click on the Draw a marker button on a new map.