-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2954 from catalyst-cooperative/nightly-build-2023…
…-10-19 Merge dev into main for 2023-10-19
- Loading branch information
Showing
8 changed files
with
197 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,11 @@ | |
from unittest.mock import patch | ||
|
||
import pandas as pd | ||
import pytest | ||
from dagster import build_op_context | ||
|
||
from pudl.extract import excel as excel | ||
from pudl.settings import DatasetsSettings | ||
|
||
|
||
class TestMetadata(unittest.TestCase): | ||
|
@@ -115,3 +118,39 @@ def test_read_excel_calls(mock_read_excel): | |
|
||
# TODO([email protected]): need to figure out how to test process_$x methods. | ||
# TODO([email protected]): we should test that empty columns are properly added. | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"dataset, expected_years", | ||
( | ||
("eia860", set(range(2001, 2022))), | ||
("eia861", set(range(2001, 2022))), | ||
("eia923", set(range(2001, 2022))), | ||
), | ||
) | ||
def test_years_from_settings(dataset, expected_years): | ||
years_from_settings = excel.years_from_settings_factory(dataset) | ||
|
||
with build_op_context( | ||
resources={"dataset_settings": DatasetsSettings()} | ||
) as context: | ||
# Assert actual years are a superset of expected. Instead of doing | ||
# an equality check, this avoids having to update expected years | ||
# every time a new year is added to the datasets | ||
assert { | ||
output.value for output in years_from_settings(context) | ||
} >= expected_years | ||
|
||
|
||
def test_concat_pages(): | ||
pages = ["page1", "page2", "page3"] | ||
dfs_1 = {page: pd.DataFrame({"df": [1], "page": [page]}) for page in pages} | ||
dfs_2 = {page: pd.DataFrame({"df": [2], "page": [page]}) for page in pages} | ||
|
||
merged_dfs = excel.concat_pages([dfs_1, dfs_2]) | ||
assert list(merged_dfs.keys()) == pages | ||
for page in pages: | ||
pd.testing.assert_frame_equal( | ||
merged_dfs[page], | ||
pd.DataFrame({"df": [1, 2], "page": [page, page]}, index=[0, 1]), | ||
) |