charasheet/src/conftest.py

45 lines
1.1 KiB
Python
Raw Normal View History

2022-10-28 22:16:23 +02:00
import pytest
from django.core.management import call_command
2023-01-16 18:02:14 +01:00
from selenium.webdriver.remote.webdriver import WebDriver
2022-10-28 22:16:23 +02:00
@pytest.fixture(scope="session", autouse=True)
2023-01-29 10:38:41 +01:00
def _collectstatic():
2022-10-28 22:16:23 +02:00
call_command("collectstatic", "--clear", "--noinput", "--verbosity=0")
2022-11-10 19:23:47 +01:00
2023-01-29 10:38:41 +01:00
@pytest.fixture()
2023-01-16 18:02:14 +01:00
def live_server(settings, live_server):
2023-04-04 18:22:38 +02:00
settings.STORAGES = {
"default": {"BACKEND": "django.core.files.storage.FileSystemStorage"},
"staticfiles": {
"BACKEND": "whitenoise.storage.CompressedStaticFilesStorage",
},
}
2023-01-16 18:02:14 +01:00
return live_server
2023-01-29 10:38:41 +01:00
@pytest.fixture()
2022-11-10 19:23:47 +01:00
def firefox_options(firefox_options):
firefox_options.add_argument("-headless")
return firefox_options
2022-11-11 08:59:18 +01:00
2023-01-29 10:38:41 +01:00
@pytest.fixture()
2023-01-16 18:02:14 +01:00
def selenium(selenium: WebDriver) -> WebDriver:
selenium.implicitly_wait(3)
selenium.set_window_size(3860, 2140)
return selenium
2022-11-11 08:59:18 +01:00
@pytest.fixture(autouse=True)
def settings(settings):
settings.DEBUG_TOOLBAR = False
return settings
2022-11-19 09:45:30 +01:00
2023-01-29 10:38:41 +01:00
@pytest.fixture()
@pytest.mark.django_db()
def initial_data() -> None: # noqa: PT004
2022-11-19 09:45:30 +01:00
call_command("loaddata", "initial_data")