chore: attempt to fix randomly failing test

This commit is contained in:
Yohan Boniface 2024-02-20 13:59:59 +01:00
parent 2fa1d42ee7
commit eb755c02c6
2 changed files with 6 additions and 5 deletions

View file

@ -5,8 +5,6 @@ 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 umap.models import Map
from .base import ( from .base import (
DataLayerFactory, DataLayerFactory,
LicenceFactory, LicenceFactory,

View file

@ -1,6 +1,7 @@
import re import re
import shutil import shutil
import tempfile import tempfile
from copy import deepcopy
import pytest import pytest
from django.core.management import call_command from django.core.management import call_command
@ -12,6 +13,11 @@ from playwright.sync_api import expect
def staticfiles(settings): def staticfiles(settings):
static_root = tempfile.mkdtemp(prefix="test_static") static_root = tempfile.mkdtemp(prefix="test_static")
settings.STATIC_ROOT = static_root settings.STATIC_ROOT = static_root
# Make sure settings are properly reset after the test
settings.STORAGES = deepcopy(settings.STORAGES)
settings.STORAGES["staticfiles"][
"BACKEND"
] = "umap.storage.UmapManifestStaticFilesStorage"
try: try:
call_command("collectstatic", "--noinput") call_command("collectstatic", "--noinput")
yield yield
@ -22,9 +28,6 @@ def staticfiles(settings):
def test_javascript_have_been_loaded( def test_javascript_have_been_loaded(
map, live_server, datalayer, page, settings, staticfiles map, live_server, datalayer, page, settings, staticfiles
): ):
settings.STORAGES["staticfiles"][
"BACKEND"
] = "umap.storage.UmapManifestStaticFilesStorage"
datalayer.settings["displayOnLoad"] = False datalayer.settings["displayOnLoad"] = False
datalayer.save() datalayer.save()
map.settings["properties"]["defaultView"] = "latest" map.settings["properties"]["defaultView"] = "latest"