Skip to content

Commit

Permalink
Parametrized build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
movchan74 committed Nov 2, 2023
1 parent 6303290 commit 8c351b1
Showing 1 changed file with 19 additions and 36 deletions.
55 changes: 19 additions & 36 deletions aana/tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,47 +114,30 @@
}


def test_get_configuration_success():
@pytest.mark.parametrize(
"target, expected_nodes, expected_deployments",
[
("lowercase", ["text", "lowercase"], {"Lowercase": "Lowercase"}),
("uppercase", ["text", "uppercase"], {"Uppercase": "Uppercase"}),
(
"both",
["text", "lowercase", "uppercase"],
{"Lowercase": "Lowercase", "Uppercase": "Uppercase"},
),
],
)
def test_get_configuration_success(target, expected_nodes, expected_deployments):
"""
Test if get_configuration returns the correct configuration
Test if get_configuration returns the correct configuration for various targets
"""
configuration = get_configuration(target, endpoints, nodes, deployments)
assert configuration["endpoints"] == endpoints[target]

# Test lowercase target

configuration = get_configuration("lowercase", endpoints, nodes, deployments)
assert configuration["endpoints"] == endpoints["lowercase"]
# nodes should have "text" and "lowercase"
node_names = [node["name"] for node in configuration["nodes"]]
assert "text" in node_names
assert "lowercase" in node_names
# deployments should have "Lowercase"
assert configuration["deployments"] == {"Lowercase": "Lowercase"}

# Test uppercase target

configuration = get_configuration("uppercase", endpoints, nodes, deployments)
assert configuration["endpoints"] == endpoints["uppercase"]
# nodes should have "text" and "uppercase"
node_names = [node["name"] for node in configuration["nodes"]]
assert "text" in node_names
assert "uppercase" in node_names
# deployments should have "Uppercase"
assert configuration["deployments"] == {"Uppercase": "Uppercase"}
for expected_node in expected_nodes:
assert expected_node in node_names

# Test both target

configuration = get_configuration("both", endpoints, nodes, deployments)
assert configuration["endpoints"] == endpoints["both"]
# nodes should have "text", "lowercase" and "uppercase"
node_names = [node["name"] for node in configuration["nodes"]]
assert "text" in node_names
assert "lowercase" in node_names
assert "uppercase" in node_names
# deployments should have "Lowercase" and "Uppercase"
assert configuration["deployments"] == {
"Lowercase": "Lowercase",
"Uppercase": "Uppercase",
}
assert configuration["deployments"] == expected_deployments


def test_get_configuration_invalid_target():
Expand Down

0 comments on commit 8c351b1

Please sign in to comment.