Skip to content

Current sensor: add small unit test #966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions tests/unit/test_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ def test_handle_id_not_found_error():
PowerGridModel(input_data={"node": node_input, "source": source_input})


def test_handle_invalid_measured_object_error():
@pytest.mark.parametrize("sensor_type", ["sym_power_sensor", "sym_current_sensor"])
def test_handle_invalid_measured_object_error(sensor_type):
node_input = initialize_array("input", "node", 2)
node_input["id"] = [0, 1]
node_input["u_rated"] = [0.0, 0.0]
Expand All @@ -240,13 +241,13 @@ def test_handle_invalid_measured_object_error():
link_input["from_node"] = [0]
link_input["to_node"] = [1]

sym_power_sensor_input = initialize_array("input", "sym_power_sensor", 1)
sym_power_sensor_input["id"] = [3]
sym_power_sensor_input["measured_object"] = [2]
sym_power_sensor_input["measured_terminal_type"] = [MeasuredTerminalType.branch_from]
sensor_input = initialize_array("input", sensor_type, 1)
sensor_input["id"] = [3]
sensor_input["measured_object"] = [2]
sensor_input["measured_terminal_type"] = [MeasuredTerminalType.branch_from]

with pytest.raises(InvalidMeasuredObject):
PowerGridModel(input_data={"node": node_input, "link": link_input, "sym_power_sensor": sym_power_sensor_input})
PowerGridModel(input_data={"node": node_input, "link": link_input, sensor_type: sensor_input})


def test_handle_invalid_regulated_object_error():
Expand Down
Loading