Skip to content

Commit

Permalink
chore: revert to old setup structure for ferc1 output test
Browse files Browse the repository at this point in the history
The main improvement I see to the test setup is to make the graph definitions more atomic.
Currently we have the graph definitions split between node creation in setup and edge definition in the tests themselves.
  • Loading branch information
jdangerx committed Jan 14, 2025
1 parent ef41da5 commit 4a81e14
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions test/unit/output/ferc1_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@


class TestForestSetup:
"""Base class for forest testing."""

def _exploded_calcs_from_edges(self, edges: list[tuple[NodeId, NodeId]]):
records = []
for parent, child in edges:
Expand Down Expand Up @@ -86,10 +84,8 @@ def build_forest_and_annotated_tags(
return annotated_tags


class TestPrunnedNode(TestForestSetup):
@pytest.fixture(autouse=True)
def setup_nodes(self):
"""Setup nodes for testing."""
class TestPrunedNode(TestForestSetup):
def setup_method(self):
self.root = NodeId(
table_name="table_1",
xbrl_factoid="reported_1",
Expand Down Expand Up @@ -120,7 +116,6 @@ def setup_nodes(self):
)

def test_pruned_nodes(self):
"""Test pruned nodes."""
edges = [(self.root, self.root_child), (self.root_other, self.root_other_child)]
tags = pd.DataFrame(columns=list(NodeId._fields)).convert_dtypes()
forest = XbrlCalculationForestFerc1(
Expand All @@ -133,11 +128,7 @@ def test_pruned_nodes(self):


class TestTagPropagation(TestForestSetup):
"""Test tag propagation functionality."""

@pytest.fixture(autouse=True)
def setup_nodes(self):
"""Setup nodes for testing."""
def setup_method(self):
self.parent = NodeId(
table_name="table_1",
xbrl_factoid="reported_1",
Expand Down Expand Up @@ -189,7 +180,6 @@ def setup_nodes(self):
)

def test_leafward_prop_undecided_children(self):
"""Test leadward propagation with undecided children."""
edges = [(self.parent, self.child1), (self.parent, self.child2)]
tags = pd.DataFrame([self.parent, self.child1, self.child2]).assign(
in_rate_base=["yes", pd.NA, pd.NA]
Expand Down Expand Up @@ -374,7 +364,6 @@ def test_annotated_forest_propagates_rootward_two_layers_plus_corrections(self):


def test_get_core_ferc1_asset_description():
"""Test core FERC1 asset description extraction."""
valid_core_ferc1_asset_name = "core_ferc1__yearly_income_statements_sched114"
valid_core_ferc1_asset_name_result = get_core_ferc1_asset_description(
valid_core_ferc1_asset_name
Expand Down

0 comments on commit 4a81e14

Please sign in to comment.