Skip to content

Commit

Permalink
Merge pull request #1178 from bdrung/python3.12
Browse files Browse the repository at this point in the history
test: fix assertions for mock calls
  • Loading branch information
sc68cal authored Mar 16, 2024
2 parents 55113bf + a98d9ff commit 784e228
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions tests/unit/module_utils/test_netbox_base_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_create_netbox_object_check_mode_false(
serialized_obj, diff = mock_netbox_module._create_netbox_object(
endpoint_mock, normalized_data
)
assert endpoint_mock.create.called_once_with(normalized_data)
endpoint_mock.create.assert_called_with(normalized_data)
assert serialized_obj.serialize() == return_value
assert diff == on_creation_diff

Expand All @@ -312,7 +312,7 @@ def test_create_netbox_object_check_mode_true(
serialized_obj, diff = mock_netbox_module._create_netbox_object(
endpoint_mock, normalized_data
)
assert endpoint_mock.create.not_called()
endpoint_mock.create.assert_not_called()
assert serialized_obj == normalized_data
assert diff == on_creation_diff

Expand All @@ -322,7 +322,7 @@ def test_delete_netbox_object_check_mode_false(
):
mock_netbox_module.nb_object = nb_obj_mock
diff = mock_netbox_module._delete_netbox_object()
assert nb_obj_mock.delete.called_once()
nb_obj_mock.delete.assert_called_once()
assert diff == on_deletion_diff


Expand All @@ -332,15 +332,15 @@ def test_delete_netbox_object_check_mode_true(
mock_netbox_module.check_mode = True
mock_netbox_module.nb_object = nb_obj_mock
diff = mock_netbox_module._delete_netbox_object()
assert nb_obj_mock.delete.not_called()
nb_obj_mock.delete.assert_not_called()
assert diff == on_deletion_diff


def test_update_netbox_object_no_changes(mock_netbox_module, nb_obj_mock):
mock_netbox_module.nb_object = nb_obj_mock
unchanged_data = nb_obj_mock.serialize()
serialized_object, diff = mock_netbox_module._update_netbox_object(unchanged_data)
assert nb_obj_mock.update.not_called()
nb_obj_mock.update.assert_not_called()
assert serialized_object == unchanged_data
assert diff is None

Expand All @@ -352,7 +352,7 @@ def test_update_netbox_object_with_changes_check_mode_false(
serialized_obj, diff = mock_netbox_module._update_netbox_object(
changed_serialized_obj
)
assert nb_obj_mock.update.called_once_with(changed_serialized_obj)
nb_obj_mock.update.assert_called_once_with(changed_serialized_obj)
assert serialized_obj == nb_obj_mock.serialize()
assert diff == on_update_diff

Expand All @@ -368,7 +368,7 @@ def test_update_netbox_object_with_changes_check_mode_true(
serialized_obj, diff = mock_netbox_module._update_netbox_object(
changed_serialized_obj
)
assert nb_obj_mock.update.not_called()
nb_obj_mock.update.assert_not_called()
assert serialized_obj == updated_serialized_obj
assert diff == on_update_diff

Expand Down

0 comments on commit 784e228

Please sign in to comment.