mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
* stash some changes * add more robust testing * mypy * point PR at V5 * introduce spec file * codespell * test fix * fix workflow environment setup * fix workflow environment setup * fix workflow environment setup * add pyyaml to dependencies * split lint jobs * fix workflow environment setup * fix workflow environment setup * workflow env setup * workflow env setup * clean up code comments * add auth hook entrypoints * codespell * add codegen feature * codespell * move _unpack into dispatchers for consistency with codegen packages * surface nested models in the response * fix missing coverage in CI * socrata updates * test fix * detect plotly output * add --include and --exclude flags from generate-extension command * refactor openbb-platform-api for V5 operations and spec file handling * delete poetry.lock * add test workflow * add temp branch id for test workflow * add httpx to dev dependencies * add a conftest.py * tweak conftest * tweak conftest * python 3.10 issues * more python 3.10 * more python 3.10 * more python 3.10 * more python 3.10 * fix url template resolution * multi-spec support * fix a windows path issue * merge branch develop * table builder, integration tests, and more * linting * merge branch develop * bit of cleanup * some more updates, cleanup, and apps.json * codespell * black * integration test params and linting * mypy * pylint * black * more pylint * recapture teest cassettes * black again * more linting * table presentation choices * black * fix merge conflict * split up metadata module and reformat cache to use msgpack * mypy * regenerate lock file * use json and include dependencies to make openbb-oecd a standalone install * pylint * more linting * serve metadata as dependency instead of assign and initialize * fix integration_tests_testers to not count dependency injections as paramters * add assets to git ignore * ruff * v5 refactor and publish workflow * test coverage and ty fixes * codespell * update lock file * workflow setup * ty check * workflow setup * Scope PR to OECD changes only Restore non-OECD files in the diff against v5 to their v5 state. The branch was originally created off feature/cli-2 and inherited 186 files of unrelated changes (cli, agent_server, mcp_server, platform_api, core/, .github/workflows/* not oecd). Those have nothing to do with the openbb-oecd v5 refactor and were polluting the PR diff. * scope cleanup: include leaked v5-resident files (general-linting workflow, platform_api test fixtures) --------- Co-authored-by: deeleeramone <> Co-authored-by: Copilot <copilot@github.com>
111 lines
2.8 KiB
Python
111 lines
2.8 KiB
Python
"""Shared fixtures for the OECD test suite."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from openbb_oecd.utils.metadata import OecdMetadata
|
|
|
|
_FULL_ID = "DSD_TEST@DF_TEST"
|
|
_SHORT_ID = "DF_TEST"
|
|
|
|
_TEST_DATAFLOW = {
|
|
"id": _FULL_ID,
|
|
"short_id": _SHORT_ID,
|
|
"agency_id": "OECD",
|
|
"version": "1.0",
|
|
"name": "Test Dataflow",
|
|
"description": "",
|
|
"structure_ref": "",
|
|
}
|
|
|
|
_TEST_DSD = {
|
|
"dsd_id": "DSD_TEST",
|
|
"agency_id": "OECD",
|
|
"version": "1.0",
|
|
"dimensions": [
|
|
{
|
|
"id": "REF_AREA",
|
|
"position": 1,
|
|
"codelist_id": "OECD:CL_AREA(1.0)",
|
|
"concept_id": "REF_AREA",
|
|
"name": "Reference Area",
|
|
},
|
|
{
|
|
"id": "MEASURE",
|
|
"position": 2,
|
|
"codelist_id": "OECD:CL_MEASURE(1.0)",
|
|
"concept_id": "MEASURE",
|
|
"name": "Measure",
|
|
},
|
|
{
|
|
"id": "FREQ",
|
|
"position": 3,
|
|
"codelist_id": "OECD:CL_FREQ(1.0)",
|
|
"concept_id": "FREQ",
|
|
"name": "Frequency",
|
|
},
|
|
],
|
|
"attributes": [],
|
|
"has_time_dimension": True,
|
|
}
|
|
|
|
_TEST_CODELISTS = {
|
|
"OECD:CL_AREA(1.0)": {
|
|
"USA": "United States",
|
|
"GBR": "United Kingdom",
|
|
"DEU": "Germany",
|
|
},
|
|
"OECD:CL_MEASURE(1.0)": {
|
|
"CPI": "Consumer Price Index",
|
|
"PPI": "Producer Price Index",
|
|
},
|
|
"OECD:CL_FREQ(1.0)": {"A": "Annual", "Q": "Quarterly", "M": "Monthly"},
|
|
}
|
|
|
|
_TEST_CONSTRAINTS = {
|
|
_FULL_ID: {
|
|
"REF_AREA": ["USA", "GBR"],
|
|
"MEASURE": ["CPI"],
|
|
"FREQ": ["A", "Q"],
|
|
}
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def seeded_meta(monkeypatch):
|
|
"""Fresh OecdMetadata singleton with test data pre-loaded, no I/O."""
|
|
OecdMetadata._reset()
|
|
monkeypatch.setattr(OecdMetadata, "_load_from_cache", lambda self: True)
|
|
instance = OecdMetadata()
|
|
instance.dataflows[_FULL_ID] = _TEST_DATAFLOW.copy()
|
|
instance._short_id_map[_SHORT_ID] = _FULL_ID
|
|
instance._full_catalogue_loaded = True
|
|
instance.datastructures[_FULL_ID] = {
|
|
"dsd_id": "DSD_TEST",
|
|
"agency_id": "OECD",
|
|
"version": "1.0",
|
|
"dimensions": [dict(d) for d in _TEST_DSD["dimensions"]],
|
|
"attributes": [],
|
|
"has_time_dimension": True,
|
|
}
|
|
instance.codelists.update({k: dict(v) for k, v in _TEST_CODELISTS.items()})
|
|
instance._dataflow_constraints.update(
|
|
{
|
|
k: {dk: list(dv) for dk, dv in v.items()}
|
|
for k, v in _TEST_CONSTRAINTS.items()
|
|
}
|
|
)
|
|
yield instance
|
|
OecdMetadata._reset()
|
|
|
|
|
|
@pytest.fixture
|
|
def empty_meta(monkeypatch):
|
|
"""Fresh OecdMetadata singleton with nothing loaded (and no I/O)."""
|
|
OecdMetadata._reset()
|
|
monkeypatch.setattr(OecdMetadata, "_load_from_cache", lambda self: True)
|
|
inst = OecdMetadata()
|
|
yield inst
|
|
OecdMetadata._reset()
|