Skip to content

Commit

Permalink
add tests to cover a few uncovered lines
Browse files Browse the repository at this point in the history
  • Loading branch information
cmgosnell committed Dec 12, 2023
1 parent bbef1e2 commit bfe6203
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/pudl/extract/epacems.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ def year(self):
"""Return the year associated with the year_quarter."""
return pd.to_datetime(self.year_quarter).year

def get_key(self):
"""Returns hashable key for use with EpaCemsDatastore."""
return self.year_quarter

def get_filters(self):
"""Returns filters for retrieving given partition resource from Datastore."""
return {"year_quarter": self.year_quarter}
Expand Down
9 changes: 9 additions & 0 deletions test/integration/epacems_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ def test_epacems_parallel(pudl_engine, epacems_parquet_path):
).compute()
assert df.year.unique() == [2022]
assert df.state.unique() == ["ME"]


def test_missing_cems_partition(pudl_datastore_fixture):
"""Test that the extract step returns an empty df.
Note: This could be a unit test, but it interacts with zenodo which is sometimes
slow. It must retrive the datapacakge.json associated with the archive.
"""
assert extract("2051q4", ds=pudl_datastore_fixture).empty
8 changes: 8 additions & 0 deletions test/unit/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def test_default_quarters(self: Self):
]
assert expected_year_quarters == returned_settings.year_quarters

def test_all_year_quarters(self: Self):
"""Test the `all` option for the cems settings."""
epacems_settings_all = EpaCemsSettings(year_quarters=["all"])
working_partitions_all = DataSource.from_id("epacems").working_partitions[
"year_quarters"
]
assert epacems_settings_all.year_quarters == working_partitions_all

def test_none_quarters_raise(self: Self):
"""Test that setting a required partition to None raises an error."""
with pytest.raises(ValidationError):
Expand Down

0 comments on commit bfe6203

Please sign in to comment.