mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-24 02:24:20 -08:00
* update Python version on README; tuple typing fix * Alaska tribal points fix (#1821) * Bump mistune from 0.8.4 to 2.0.3 in /data/data-pipeline (#1777) Bumps [mistune](https://github.com/lepture/mistune) from 0.8.4 to 2.0.3. - [Release notes](https://github.com/lepture/mistune/releases) - [Changelog](https://github.com/lepture/mistune/blob/master/docs/changes.rst) - [Commits](https://github.com/lepture/mistune/compare/v0.8.4...v2.0.3) --- updated-dependencies: - dependency-name: mistune dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * poetry update * initial pass of score tests * add threshold tests * added ses threshold (not donut, not island) * testing suite -- stopping for the day * added test for lead proxy indicator * Refactor score tests to make them less verbose and more direct (#1865) * Cleanup tests slightly before refactor (#1846) * Refactor score calculations tests * Feedback from review * Refactor output tests like calculatoin tests (#1846) (#1870) * Reorganize files (#1846) * Switch from lru_cache to fixture scorpes (#1846) * Add tests for all factors (#1846) * Mark smoketests and run as part of be deply (#1846) * Update renamed var (#1846) * Switch from named tuple to dataclass (#1846) This is annoying, but pylint in python3.8 was crashing parsing the named tuple. We weren't using any namedtuple-specific features, so I made the type a dataclass just to get pylint to behave. * Add default timout to requests (#1846) * Fix type (#1846) * Fix merge mistake on poetry.lock (#1846) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Jorge Escobar <jorge.e.escobar@omb.eop.gov> Co-authored-by: Jorge Escobar <83969469+esfoobar-usds@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Matt Bowen <83967628+mattbowen-usds@users.noreply.github.com> Co-authored-by: matt bowen <matthew.r.bowen@omb.eop.gov>
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
import os
|
|
from pathlib import Path
|
|
from shutil import copyfile
|
|
|
|
import pytest
|
|
|
|
from data_pipeline.config import settings
|
|
from data_pipeline.etl.base import ExtractTransformLoad
|
|
|
|
TMP_DIR = settings.APP_ROOT / "data" / "tmp" / "tests"
|
|
|
|
|
|
def copy_data_files(src: Path, dst: Path) -> None:
|
|
"""Copies test data from src Path to dst Path for use in testing
|
|
|
|
Args
|
|
src: pathlib.Path instance. The location of the source data file.
|
|
dst: pathlib.Path instance. Where to copy the source data file to.
|
|
|
|
Returns
|
|
None. This is a void function
|
|
"""
|
|
if not dst.exists():
|
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
copyfile(src, dst)
|
|
assert dst.exists()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def mock_paths(tmp_path_factory) -> tuple:
|
|
"""Creates new DATA_PATH and TMP_PATH that point to a temporary local
|
|
file structure that can be used to mock data folder during testing
|
|
"""
|
|
# sets location of the temp directory inside the national_risk_index folder
|
|
os.environ["PYTEST_DEBUG_TEMPROOT"] = str(TMP_DIR)
|
|
TMP_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
# creates DATA_PATH and TMP_PATH directories in temp directory
|
|
data_path = tmp_path_factory.mktemp("data", numbered=False)
|
|
tmp_path = data_path / "tmp"
|
|
tmp_path.mkdir()
|
|
|
|
return data_path, tmp_path
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_etl(monkeypatch, mock_paths) -> None:
|
|
"""Creates a mock version of the base ExtractTransformLoad class and resets
|
|
global the variables for DATA_PATH and TMP_PATH to the local mock_paths
|
|
"""
|
|
data_path, tmp_path = mock_paths
|
|
monkeypatch.setattr(ExtractTransformLoad, "DATA_PATH", data_path)
|
|
monkeypatch.setattr(ExtractTransformLoad, "TMP_PATH", tmp_path)
|
|
|
|
|
|
def pytest_collection_modifyitems(config, items):
|
|
keywordexpr = config.option.keyword
|
|
markexpr = config.option.markexpr
|
|
if keywordexpr or markexpr:
|
|
return # let pytest handle this
|
|
|
|
smoketest = "smoketest"
|
|
skip_mymarker = pytest.mark.skip(reason=f"{smoketest} not selected")
|
|
for item in items:
|
|
if smoketest in item.keywords:
|
|
item.add_marker(skip_mymarker)
|