Skip to content

Commit

Permalink
fix(conflict-handling): on conflict, hit GET api to return full detai…
Browse files Browse the repository at this point in the history
…ls (#51)
  • Loading branch information
Avantol13 authored Dec 20, 2018
1 parent 8a9a46b commit 0cd06b2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cirrus/google_cloud/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ def create_group(self, name, email=None):
if err.resp.status == 409:
# conflict, group already exists. This is fine, don't raise an
# error, pass back group
return group
return self.get_group(group["email"])

raise

Expand Down
15 changes: 15 additions & 0 deletions test/test_google_cloud_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,25 @@ def test_create_group_already_exists(test_cloud_manager):
}
test_cloud_manager._admin_service.configure_mock(**mock_config)

test_cloud_manager.get_group = MagicMock()
test_cloud_manager.get_group.return_value = {
"kind": "admin#directory#group",
"id": "123456",
"etag": "",
"email": new_group_email,
"name": new_group_name,
"directMembersCount": 0,
"description": "",
"adminCreated": False,
"aliases": [""],
"nonEditableAliases": [""],
}

# Call #
group = test_cloud_manager.create_group(name=new_group_name, email=new_group_email)

# Test #
assert group["id"]
assert group["email"] == new_group_email
assert group["name"] == new_group_name

Expand Down

0 comments on commit 0cd06b2

Please sign in to comment.