-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: save empty IAM policy bindings (#155)
- Loading branch information
1 parent
b4860fe
commit 536c2ca
Showing
2 changed files
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,11 @@ def test_ctor_defaults(self): | |
policy = self._make_one() | ||
assert policy.etag is None | ||
assert policy.version is None | ||
assert len(policy) == 0 | ||
assert dict(policy) == {} | ||
assert policy.owners == empty | ||
assert policy.editors == empty | ||
assert policy.viewers == empty | ||
assert len(policy) == 0 | ||
assert dict(policy) == {} | ||
|
||
def test_ctor_explicit(self): | ||
VERSION = 1 | ||
|
@@ -45,16 +45,24 @@ def test_ctor_explicit(self): | |
policy = self._make_one(ETAG, VERSION) | ||
assert policy.etag == ETAG | ||
assert policy.version == VERSION | ||
assert len(policy) == 0 | ||
assert dict(policy) == {} | ||
assert policy.owners == empty | ||
assert policy.editors == empty | ||
assert policy.viewers == empty | ||
assert len(policy) == 0 | ||
assert dict(policy) == {} | ||
|
||
def test___getitem___miss(self): | ||
policy = self._make_one() | ||
assert policy["nonesuch"] == set() | ||
|
||
def test__getitem___and_set(self): | ||
from google.api_core.iam import OWNER_ROLE | ||
policy = self._make_one() | ||
|
||
# get the policy using the getter and then modify it | ||
policy[OWNER_ROLE].add("user:[email protected]") | ||
assert dict(policy) == {OWNER_ROLE: {"user:[email protected]"}} | ||
|
||
def test___getitem___version3(self): | ||
policy = self._make_one("DEADBEEF", 3) | ||
with pytest.raises(InvalidOperationException, match=_DICT_ACCESS_MSG): | ||
|
@@ -293,10 +301,10 @@ def test_from_api_repr_only_etag(self): | |
policy = klass.from_api_repr(RESOURCE) | ||
assert policy.etag == "ACAB" | ||
assert policy.version is None | ||
assert dict(policy) == {} | ||
assert policy.owners == empty | ||
assert policy.editors == empty | ||
assert policy.viewers == empty | ||
assert dict(policy) == {} | ||
|
||
def test_from_api_repr_complete(self): | ||
from google.api_core.iam import OWNER_ROLE, EDITOR_ROLE, VIEWER_ROLE | ||
|