Skip to content

Commit

Permalink
Added equals test
Browse files Browse the repository at this point in the history
  • Loading branch information
njriasan committed Nov 10, 2024
1 parent e32117b commit 793a6ce
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions tests/test_relational.py
Original file line number Diff line number Diff line change
Expand Up @@ -2322,8 +2322,66 @@ def test_root_to_string(root: RelationalRoot, output: str):
assert root.to_string() == output


# def test_root_equals(first_root: RelationalRoot, second_root: Relational, output: bool):
# assert first_root.equals(second_root) == output
@pytest.mark.parametrize(
"first_root, second_root, output",
[
pytest.param(
RelationalRoot(build_simple_scan(), [make_column("a"), make_column("b")]),
RelationalRoot(build_simple_scan(), [make_column("a"), make_column("b")]),
True,
id="matching_columns_no_orderings",
),
pytest.param(
RelationalRoot(build_simple_scan(), [make_column("a"), make_column("b")]),
RelationalRoot(build_simple_scan(), [make_column("b"), make_column("c")]),
False,
id="different_columns_no_orderings",
),
pytest.param(
RelationalRoot(
build_simple_scan(),
[make_column("a"), make_column("b")],
[make_simple_column_reference("a")],
),
RelationalRoot(
build_simple_scan(),
[make_column("a"), make_column("b")],
[make_simple_column_reference("a")],
),
True,
id="matching_columns_with_orderings",
),
pytest.param(
RelationalRoot(
build_simple_scan(),
[make_column("a"), make_column("b")],
[make_simple_column_reference("a")],
),
RelationalRoot(
build_simple_scan(),
[make_column("a"), make_column("b")],
[make_simple_column_reference("b")],
),
False,
id="different_orderings",
),
pytest.param(
RelationalRoot(build_simple_scan(), [make_column("a"), make_column("b")]),
RelationalRoot(Scan("table2", []), [make_column("a"), make_column("b")]),
False,
id="different_inputs",
),
pytest.param(
RelationalRoot(build_simple_scan(), [make_column("a"), make_column("b")]),
Scan("table2", [make_column("a"), make_column("b")]),
False,
id="different_nodes",
),
],
)
def test_root_equals(first_root: RelationalRoot, second_root: Relational, output: bool):
assert first_root.equals(second_root) == output


# def test_root_can_merge(first_root: RelationalRoot, second_root: RelationalRoot):
# assert not first_root.can_merge(second_root)
Expand Down

0 comments on commit 793a6ce

Please sign in to comment.