From 415af5b31e0dd6d1cde4740439efef38b3d5f5ba Mon Sep 17 00:00:00 2001 From: matt bowen Date: Tue, 2 Aug 2022 10:59:18 -0400 Subject: [PATCH] Add output-path tests (#1518) --- .../sources/child_opportunity_index/test_etl.py | 11 +++++++++++ .../tests/sources/doe_energy_burden/test_etl.py | 13 ++++++++++++- .../tests/sources/national_risk_index/test_etl.py | 2 -- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/data/data-pipeline/data_pipeline/tests/sources/child_opportunity_index/test_etl.py b/data/data-pipeline/data_pipeline/tests/sources/child_opportunity_index/test_etl.py index f246a0c0..7183f911 100644 --- a/data/data-pipeline/data_pipeline/tests/sources/child_opportunity_index/test_etl.py +++ b/data/data-pipeline/data_pipeline/tests/sources/child_opportunity_index/test_etl.py @@ -56,3 +56,14 @@ class TestChildOpportunityIndexETL(TestETL): assert etl.HEALTHY_FOOD_INPUT_FIELD == "HE_FOOD" assert etl.IMPENETRABLE_SURFACES_INPUT_FIELD == "HE_GREEN" assert etl.READING_INPUT_FIELD == "ED_READING" + + def test_get_output_file_path(self, mock_etl, mock_paths): + """Tests the right file name is returned.""" + etl = self._ETL_CLASS() + data_path, tmp_path = mock_paths + + output_file_path = etl._get_output_file_path() + expected_output_file_path = ( + data_path / "dataset" / "child_opportunity_index" / "usa.csv" + ) + assert output_file_path == expected_output_file_path diff --git a/data/data-pipeline/data_pipeline/tests/sources/doe_energy_burden/test_etl.py b/data/data-pipeline/data_pipeline/tests/sources/doe_energy_burden/test_etl.py index c3eaf667..efa70d57 100644 --- a/data/data-pipeline/data_pipeline/tests/sources/doe_energy_burden/test_etl.py +++ b/data/data-pipeline/data_pipeline/tests/sources/doe_energy_burden/test_etl.py @@ -15,7 +15,7 @@ class TestDOEEnergyBurdenETL(TestETL): This uses pytest-snapshot. To update individual snapshots: $ poetry run pytest - data_pipeline/tests/sources/ndoe_energy_burden/test_etl.py::TestClassNameETL:: + data_pipeline/tests/sources/doe_energy_burden/test_etl.py::TestClassNameETL:: --snapshot-update """ @@ -48,3 +48,14 @@ class TestDOEEnergyBurdenETL(TestETL): assert etl.INPUT_GEOID_TRACT_FIELD_NAME == "FIP" assert etl.INPUT_ENERGY_BURDEN_FIELD_NAME == "BURDEN" assert etl.REVISED_ENERGY_BURDEN_FIELD_NAME == "Energy burden" + + def test_get_output_file_path(self, mock_etl, mock_paths): + """Tests the right file name is returned.""" + etl = self._ETL_CLASS() + data_path, tmp_path = mock_paths + + output_file_path = etl._get_output_file_path() + expected_output_file_path = ( + data_path / "dataset" / "doe_energy_burden" / "usa.csv" + ) + assert output_file_path == expected_output_file_path diff --git a/data/data-pipeline/data_pipeline/tests/sources/national_risk_index/test_etl.py b/data/data-pipeline/data_pipeline/tests/sources/national_risk_index/test_etl.py index 4892e40a..5839c61d 100644 --- a/data/data-pipeline/data_pipeline/tests/sources/national_risk_index/test_etl.py +++ b/data/data-pipeline/data_pipeline/tests/sources/national_risk_index/test_etl.py @@ -1,7 +1,5 @@ # pylint: disable=protected-access -from unittest import mock import pathlib -import requests from data_pipeline.etl.base import ValidGeoLevel from data_pipeline.etl.sources.national_risk_index.etl import (