Skip to content

Commit

Permalink
Move test to base for broader coverage (#1848)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbowen-usds committed Sep 21, 2022
1 parent aca2261 commit 4ddc744
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,3 @@ def test_get_output_file_path(self, mock_etl, mock_paths):
data_path / "dataset" / "doe_energy_burden" / "usa.csv"
)
assert output_file_path == expected_output_file_path

def test_tract_id_lengths(self, mock_etl, mock_paths):
etl = self._setup_etl_instance_and_run_extract(
mock_etl=mock_etl, mock_paths=mock_paths
)
etl.transform()
etl.validate()
etl.load()
df = etl.get_data_frame()
assert (df[etl.GEOID_TRACT_FIELD_NAME].str.len() == 11).all()
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,10 @@ def test_tracts_without_fuds_not_in_results(self, mock_etl, mock_paths):
assert len(df[etl.GEOID_TRACT_FIELD_NAME]) == len(
self._FIXTURES_SHARED_TRACT_IDS
)

def test_tract_id_lengths(self, mock_etl, mock_paths):
with mock.patch(
"data_pipeline.etl.sources.eamlis.etl.add_tracts_for_geometries",
new=_fake_add_tracts_for_geometries,
):
super().test_tract_id_lengths(mock_etl, mock_paths)
10 changes: 10 additions & 0 deletions data/data-pipeline/data_pipeline/tests/sources/example/test_etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,16 @@ def test_get_output_file_path_base(self, mock_etl, mock_paths):

assert actual_file_path == expected_file_path

def test_tract_id_lengths(self, mock_etl, mock_paths):
etl = self._setup_etl_instance_and_run_extract(
mock_etl=mock_etl, mock_paths=mock_paths
)
etl.transform()
etl.validate()
etl.load()
df = etl.get_data_frame()
assert (df[etl.GEOID_TRACT_FIELD_NAME].str.len() == 11).all()

def test_fixtures_contain_shared_tract_ids_base(self, mock_etl, mock_paths):
"""Check presence of necessary shared tract IDs.
Note: We used shared census tract IDs so that later our tests can join all the
Expand Down

0 comments on commit 4ddc744

Please sign in to comment.