use new DIR fixture

This commit is contained in:
Daniel 2023-11-27 14:28:52 +01:00
parent 387d5f1822
commit f38763d912

View file

@ -4,18 +4,20 @@ from pathlib import Path
import pytest import pytest
from playwright.sync_api import BrowserContext from playwright.sync_api import BrowserContext
from src.dirmanager import DirManager
@pytest.fixture @pytest.fixture
def admin_session(context: BrowserContext, STATES: Path) -> BrowserContext: def admin_session(context: BrowserContext, DIR: DirManager) -> BrowserContext:
state_file = STATES / "admin_state.json" state_file = DIR.STATES / "admin_state.json"
storage_state = json.loads(state_file.read_bytes()) storage_state = json.loads(state_file.read_bytes())
context.add_cookies(storage_state["cookies"]) context.add_cookies(storage_state["cookies"])
return context return context
@pytest.fixture @pytest.fixture
def user_session(context: BrowserContext, STATES: Path) -> BrowserContext: def user_session(context: BrowserContext, DIR: Path) -> BrowserContext:
state_file = STATES / "user_state.json" state_file = DIR.STATES / "user_state.json"
storage_state = json.loads(state_file.read_bytes()) storage_state = json.loads(state_file.read_bytes())
context.add_cookies(storage_state["cookies"]) context.add_cookies(storage_state["cookies"])
return context return context