Skip to content

Commit

Permalink
Fix tests on GoogleAdmin, expect new response structure
Browse files Browse the repository at this point in the history
  • Loading branch information
austinweisgrau committed Jun 21, 2024
1 parent c87fc62 commit fc20351
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions test/test_google/test_google_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,41 @@ def setUp(self):
self.google_admin = MockGoogleAdmin()

def test_aliases(self):
self.google_admin.client.request = MagicMock(
return_value=(
"",
'{"aliases": [{"alias": "[email protected]"},'
'{"alias": "fakeemail8@fakedomain'
'.com"}]}'.encode(),
)
)
response_mock = MagicMock()
self.google_admin.client.request = MagicMock(return_value=response_mock)
response_mock.json.return_value = {
"aliases": [
{"alias": "fakeemail7@fakedomain.com"},
{"alias": "fakeemail8@fakedomain.com"},
]
}
assert_matching_tables(self.google_admin.get_aliases("1"), self.mock_aliases)

def test_all_group_members(self):
self.google_admin.client.request = MagicMock(
return_value=(
"",
'{"members": [{"email": "[email protected]"}]}'.encode(),
)
)
response_mock = MagicMock()
self.google_admin.client.request = MagicMock(return_value=response_mock)
response_mock.json.return_value = {"members": [{"email": "[email protected]"}]}
assert_matching_tables(
self.google_admin.get_all_group_members("1"), self.mock_all_group_members
)

def test_all_groups(self):
self.google_admin.client.request = MagicMock(
return_value=(
"",
'{"groups": [{"aliases": ["[email protected]", "[email protected]"], "e' # noqa: E501
'mail": "[email protected]", "id": 1}, {"email": "[email protected]", "' # noqa: E501
'id": 2}, {"email": "[email protected]", "id": 3}]}'.encode(),
)
)
response_mock = MagicMock()
self.google_admin.client.request = MagicMock(return_value=response_mock)
response_mock.json.return_value = {
"groups": [
{
"aliases": [
"[email protected]",
"[email protected]",
],
"email": "[email protected]",
"id": 1,
},
{"email": "[email protected]", "id": 2},
{"email": "[email protected]", "id": 3},
]
}
assert_matching_tables(
self.google_admin.get_all_groups({"domain": "fakedomain.com"}),
self.mock_all_groups,
Expand Down

0 comments on commit fc20351

Please sign in to comment.