use get_config and BaseUrl in fixtures

This commit is contained in:
Daniel 2023-12-05 23:46:39 +01:00
parent ef0d9c9415
commit db2a34c7a7

View file

@ -1,10 +1,10 @@
import json import json
import pytest import pytest
from dotenv import dotenv_values
from playwright.sync_api import BrowserContext, Page from playwright.sync_api import BrowserContext, Page
from abratest.dir_manager import DirManager from abratest.dir_manager import DirManager
from abratest.utils import BaseUrl
@pytest.fixture @pytest.fixture
@ -18,10 +18,9 @@ def authentik_admin_context(context: BrowserContext, DIR: DirManager) -> Browser
@pytest.fixture @pytest.fixture
def authentik_admin_page(authentik_admin_context: BrowserContext, DIR: DirManager) -> Page: def authentik_admin_page(authentik_admin_context: BrowserContext, DIR: DirManager) -> Page:
page = authentik_admin_context.new_page() page = authentik_admin_context.new_page()
env_file = DIR.ENV_FILES / "authentik" config = DIR.get_config("authentik")
config: dict[str, str] = dotenv_values(env_file) # type: ignore base_url = BaseUrl(config["DOMAIN"])
url = "https://" + config["DOMAIN"] page.goto(base_url.get())
page.goto(url)
return page return page
@ -36,8 +35,7 @@ def authentik_user_context(context: BrowserContext, DIR: DirManager) -> BrowserC
@pytest.fixture @pytest.fixture
def authentik_user_page(authentik_user_context: BrowserContext, DIR: DirManager) -> Page: def authentik_user_page(authentik_user_context: BrowserContext, DIR: DirManager) -> Page:
page = authentik_user_context.new_page() page = authentik_user_context.new_page()
env_file = DIR.ENV_FILES / "authentik" config = DIR.get_config("authentik")
config: dict[str, str] = dotenv_values(env_file) # type: ignore base_url = BaseUrl(config["DOMAIN"])
url = "https://" + config["DOMAIN"] page.goto(base_url.get())
page.goto(url)
return page return page