Skip to content

Commit

Permalink
test: replace deprecated TestCase.assertEquals
Browse files Browse the repository at this point in the history
`TestCase.assertEquals` is depracated and removed in Python 3.12.

Signed-off-by: Benjamin Drung <[email protected]>
  • Loading branch information
bdrung authored and rndmh3ro committed Feb 20, 2024
1 parent 6773070 commit 25d56be
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/350-python3.12.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- "test: replace deprecated `TestCase.assertEquals` to support Python 3.12"
20 changes: 10 additions & 10 deletions tests/unit/modules/grafana/grafana_team/test_grafana_team.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def test_get_team_method_with_existing_team(self, mock_fetch_url, mock_get_versi
},
method="GET",
)
self.assertEquals(res, {"email": "[email protected]", "name": "MyTestTeam"})
self.assertEqual(res, {"email": "[email protected]", "name": "MyTestTeam"})

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_get_team_method_with_non_existing_team(
},
method="GET",
)
self.assertEquals(res, None)
self.assertEqual(res, None)

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -377,7 +377,7 @@ def test_create_team_method(self, mock_fetch_url, mock_get_version):
},
method="POST",
)
self.assertEquals(res, {"message": "Team created", "teamId": 2})
self.assertEqual(res, {"message": "Team created", "teamId": 2})

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -412,7 +412,7 @@ def test_update_team_method(self, mock_fetch_url, mock_get_version):
},
method="PUT",
)
self.assertEquals(res, {"message": "Team updated"})
self.assertEqual(res, {"message": "Team updated"})

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -445,7 +445,7 @@ def test_delete_team_method(self, mock_fetch_url, mock_get_version):
},
method="DELETE",
)
self.assertEquals(res, {"message": "Team deleted"})
self.assertEqual(res, {"message": "Team deleted"})

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -478,7 +478,7 @@ def test_get_team_members_method(self, mock_fetch_url, mock_get_version):
},
method="GET",
)
self.assertEquals(res, ["[email protected]", "[email protected]"])
self.assertEqual(res, ["[email protected]", "[email protected]"])

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -513,7 +513,7 @@ def test_get_team_members_method_no_members_returned(
},
method="GET",
)
self.assertEquals(res, [])
self.assertEqual(res, [])

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -550,7 +550,7 @@ def test_add_team_member_method(self, mock_fetch_url, mock_get_version):
},
method="POST",
)
self.assertEquals(res, None)
self.assertEqual(res, None)

@patch(
"ansible_collections.community.grafana.plugins.modules.grafana_team.GrafanaTeamInterface.get_version"
Expand Down Expand Up @@ -587,13 +587,13 @@ def test_delete_team_member_method(self, mock_fetch_url, mock_get_version):
},
method="DELETE",
)
self.assertEquals(res, None)
self.assertEqual(res, None)

def test_diff_members_function(self):
list1 = ["[email protected]", "[email protected]"]
list2 = ["[email protected]", "[email protected]"]

res = grafana_team.diff_members(list1, list2)
self.assertEquals(
self.assertEqual(
res, {"to_del": ["[email protected]"], "to_add": ["[email protected]"]}
)
4 changes: 2 additions & 2 deletions tests/unit/modules/grafana/grafana_user/test_grafana_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_create_user_new_user(self, mock_fetch_url):

mock_fetch_url.assert_has_calls(expected_fetch_url_calls, any_order=False)

self.assertEquals(
self.assertEqual(
result,
{
"id": 2,
Expand Down Expand Up @@ -238,4 +238,4 @@ def test_delete_user(self, mock_fetch_url):
},
method="DELETE",
)
self.assertEquals(result, {"message": "User deleted"})
self.assertEqual(result, {"message": "User deleted"})

0 comments on commit 25d56be

Please sign in to comment.