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
This commit is contained in:
parent
1975b93ad8
commit
3a5174c003
2 changed files with 10 additions and 6 deletions
|
@ -5,8 +5,13 @@ import pytest
|
||||||
from django.core.cache import cache
|
from django.core.cache import cache
|
||||||
from django.core.signing import get_cookie_signer
|
from django.core.signing import get_cookie_signer
|
||||||
|
|
||||||
from .base import DataLayerFactory, MapFactory, UserFactory
|
from .base import (
|
||||||
from umap.models import Licence, TileLayer
|
DataLayerFactory,
|
||||||
|
MapFactory,
|
||||||
|
UserFactory,
|
||||||
|
TileLayerFactory,
|
||||||
|
LicenceFactory,
|
||||||
|
)
|
||||||
|
|
||||||
TMP_ROOT = tempfile.mkdtemp()
|
TMP_ROOT = tempfile.mkdtemp()
|
||||||
|
|
||||||
|
@ -37,8 +42,7 @@ def user2():
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def licence():
|
def licence():
|
||||||
# Should be created by the migrations.
|
return LicenceFactory()
|
||||||
return Licence.objects.last()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
@ -73,4 +77,4 @@ def datalayer(map):
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def tilelayer():
|
def tilelayer():
|
||||||
return TileLayer.objects.last()
|
return TileLayerFactory()
|
||||||
|
|
|
@ -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)
|
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/")
|
page.goto(f"{live_server.url}/en/map/new/")
|
||||||
|
|
||||||
# Click on the Draw a marker button on a new map.
|
# Click on the Draw a marker button on a new map.
|
||||||
|
|
Loading…
Reference in a new issue