add api fixture
This commit is contained in:
parent
c9f8a4b2a9
commit
6cfc23eb44
1 changed files with 16 additions and 6 deletions
|
|
@ -5,18 +5,16 @@ import os
|
||||||
import re
|
import re
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Protocol, TypedDict
|
from typing import Generator, Protocol, TypedDict
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from dotenv import dotenv_values
|
from dotenv import dotenv_values
|
||||||
from icecream import ic
|
from icecream import ic # type: ignore
|
||||||
from imbox import Imbox # type: ignore
|
from imbox import Imbox # type: ignore
|
||||||
from playwright.sync_api import BrowserContext, expect
|
from playwright.sync_api import APIRequestContext, BrowserContext, Playwright, expect
|
||||||
from pytest import Parser
|
from pytest import Parser
|
||||||
|
|
||||||
from pytest_abra.dir_manager import DirManager
|
from pytest_abra import BaseUrl, DirManager, EnvFile
|
||||||
from pytest_abra.env_manager import EnvFile
|
|
||||||
from pytest_abra.utils import BaseUrl
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser: Parser):
|
def pytest_addoption(parser: Parser):
|
||||||
|
|
@ -152,3 +150,15 @@ def imap_recent_messages(imap_client: Imbox) -> list[Message]:
|
||||||
messages.append(message)
|
messages.append(message)
|
||||||
|
|
||||||
return messages
|
return messages
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def api_request_context(
|
||||||
|
playwright: Playwright,
|
||||||
|
DIR: DirManager,
|
||||||
|
URL: BaseUrl,
|
||||||
|
) -> Generator[APIRequestContext, None, None]:
|
||||||
|
state_file = DIR.STATES / "authentik_admin_state.json"
|
||||||
|
request_context = playwright.request.new_context(storage_state=state_file, base_url=URL.get())
|
||||||
|
yield request_context
|
||||||
|
request_context.dispose()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue