Skip to content
Snippets Groups Projects
conftest.py 879 B
# -*- coding: utf-8 -*-
import os
from pathlib import Path

import pytest
from arkindex_export import open_database

FIXTURES = Path(__file__).resolve().parent / "data"


@pytest.fixture(autouse=True)
def setup_environment(responses):
    """Setup needed environment variables"""

    # Allow accessing remote API schemas
    # defaulting to the prod environment
    schema_url = os.environ.get(
        "ARKINDEX_API_SCHEMA_URL",
        "https://arkindex.teklia.com/api/v1/openapi/?format=openapi-json",
    )
    responses.add_passthru(schema_url)

    # Set schema url in environment
    os.environ["ARKINDEX_API_SCHEMA_URL"] = schema_url


@pytest.fixture
def database_path():
    return FIXTURES / "export.sqlite"


@pytest.fixture(autouse=True)
def demo_db(database_path):
    """
    Open connection towards a known demo database
    """
    open_database(database_path)