Skip to content

Commit

Permalink
Merge branch 'epic/full_scale_testing' into hjafari/MIC-5521_create_a…
Browse files Browse the repository at this point in the history
…nd_mark_release_tests
  • Loading branch information
hussain-jafari committed Dec 11, 2024
2 parents a693b0f + 931d723 commit 2dd6241
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ def pytest_addoption(parser: argparsing.Parser) -> None:

def pytest_configure(config: Config) -> None:
config.addinivalue_line("markers", "slow: mark test as slow to run")
config.addinivalue_line(
"markers",
"subprocess_test: mark a test to run only as a subprocess within another test",
)


def pytest_collection_modifyitems(config: Config, items: list[Function]) -> None:
Expand Down
31 changes: 16 additions & 15 deletions tests/release/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pytest
from memory_profiler import memory_usage # type: ignore

from pseudopeople.configuration import Keys, get_configuration
from pseudopeople.configuration.entities import NO_NOISE
from pseudopeople.dataset import Dataset
from pseudopeople.interface import (
Expand All @@ -21,8 +20,7 @@
generate_taxes_w2_and_1099,
generate_women_infants_and_children,
)
from pseudopeople.noise_entities import NOISE_TYPES
from pseudopeople.schema_entities import COLUMNS, DATASET_SCHEMAS
from pseudopeople.schema_entities import DATASET_SCHEMAS
from tests.utilities import initialize_dataset_with_sample


Expand Down Expand Up @@ -95,8 +93,10 @@ def pytest_addoption(parser: pytest.Parser) -> None:
@pytest.fixture(scope="session")
def release_output_dir() -> Path:
# TODO: [MIC-5522] define correct output dir
# output_dir_name = os.environ.get("PSP_TEST_OUTPUT_DIR")
output_dir_name = "/ihme/homes/hjafari/ppl_testing"
# output_dir = os.environ.get("PSP_TEST_OUTPUT_DIR")
output_dir_name = (
"/mnt/team/simulation_science/priv/engineering/pseudopeople_release_testing"
)
# if not output_dir_name:
# raise ValueError("PSP_TEST_OUTPUT_DIR environment variable not set")
output_dir = Path(output_dir_name) / f"{time.strftime('%Y%m%d_%H%M%S')}"
Expand Down Expand Up @@ -133,8 +133,8 @@ def dataset_params(


@pytest.fixture(scope="session")
def data(release_output_dir: Path, request: pytest.FixtureRequest, config: dict[str, Any]) -> pd.DataFrame:
_, dataset_func, source, year, state, engine = request.getfixturevalue("dataset_params")
def data(dataset_params: tuple[str | int | Callable[..., pd.DataFrame] | None, ...], release_output_dir: Path, request: pytest.FixtureRequest, config: dict[str, Any]) -> pd.DataFrame:
_, dataset_func, source, year, state, engine = dataset_params

if source is None:
return dataset_func(seed=0, year=None, config=config)
Expand Down Expand Up @@ -162,14 +162,15 @@ def unnoised_dataset(
if source is None:
return initialize_dataset_with_sample(dataset_name)

if dataset_func == generate_social_security:
unnoised_data = dataset_func(
source=source, year=year, engine=engine, config=NO_NOISE
)
else:
unnoised_data = dataset_func(
source=source, year=year, state=state, engine=engine, config=NO_NOISE
)
kwargs = {
"source": source,
"config": NO_NOISE,
"year": year,
"engine": engine,
}
if dataset_func != generate_social_security:
kwargs["state"] = state
unnoised_data = dataset_func(**kwargs)

dataset_schema = DATASET_SCHEMAS.get_dataset_schema(dataset_name)
return Dataset(dataset_schema, unnoised_data, SEED)
Expand Down
11 changes: 6 additions & 5 deletions tests/release/test_fixture_args.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Callable

import os
import pandas as pd
import subprocess
from pathlib import Path

Expand All @@ -18,7 +21,6 @@
CLI_DEFAULT_STATE,
CLI_DEFAULT_YEAR,
FULL_USA_FILEPATH,
RI_FILEPATH,
)


Expand Down Expand Up @@ -72,12 +74,11 @@ def check_subprocess_environment() -> None:


@pytest.mark.usefixtures("check_subprocess_environment")
def test_parsing_fixture_params(request: pytest.FixtureRequest) -> None:
output = request.getfixturevalue("dataset_params")
def test_parsing_fixture_params(dataset_params: tuple[str | int | Callable[..., pd.DataFrame] | None, ...], request: pytest.FixtureRequest) -> None:
# we know output will have a string as the first element but can't type this
# while specifying the types of the other elements in output
dataset_name: str = output[0] # type: ignore [assignment]
assert output[1:] == EXPECTED_PARAMETERS[dataset_name]
dataset_name: str = dataset_params[0] # type: ignore [assignment]
assert dataset_params[1:] == EXPECTED_PARAMETERS[dataset_name]


@pytest.mark.parametrize(
Expand Down

0 comments on commit 2dd6241

Please sign in to comment.