Skip to content

Commit

Permalink
test: Add (non-working) test for set_cache_path
Browse files Browse the repository at this point in the history
  • Loading branch information
anth-volk committed Jul 31, 2024
1 parent e5449e3 commit d97a75a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
5 changes: 4 additions & 1 deletion policyengine_core/simulations/sim_macro_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def set_cache_path(
period: str,
branch_name: str,
):
storage_folder = parent_path / f"{dataset_name}_variable_cache"
storage_folder = (
Path(parent_path)
/ f"{dataset_name}_variable_cache"
)
storage_folder.mkdir(exist_ok=True)
self.cache_file_path = (
storage_folder / f"{variable_name}_{period}_{branch_name}.h5"
Expand Down
24 changes: 24 additions & 0 deletions tests/core/test_simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ def test_version(tax_benefit_system):
)
assert cache.country_version == "0.0.0"

# Test set_cache_path
def test_set_cache_path(tax_benefit_system):
cache = SimulationMacroCache(tax_benefit_system)
cache.set_cache_path(
parent_path="tests/core",
dataset_name="test_dataset",
variable_name="test_variable",
period="2020",
branch_name="test_branch",
)
cache.set_cache_value(
cache_file_path=cache.cache_file_path,
value=3,
)
assert cache.cache_file_path == "tests/core/test_dataset_variable_cache/test_variable_2020_test_branch.h5"

# Test set_cache_value

# Test get_cache_path

# Test get_cache_value

# Test clear_cache


def test_macro_cache(tax_benefit_system):
simulation = SimulationBuilder().build_from_entities(
Expand Down

0 comments on commit d97a75a

Please sign in to comment.