@@ -32,11 +32,11 @@ def test_ctor_defaults(self):
32
32
policy = self ._make_one ()
33
33
assert policy .etag is None
34
34
assert policy .version is None
35
+ assert len (policy ) == 0
36
+ assert dict (policy ) == {}
35
37
assert policy .owners == empty
36
38
assert policy .editors == empty
37
39
assert policy .viewers == empty
38
- assert len (policy ) == 0
39
- assert dict (policy ) == {}
40
40
41
41
def test_ctor_explicit (self ):
42
42
VERSION = 1
@@ -45,16 +45,24 @@ def test_ctor_explicit(self):
45
45
policy = self ._make_one (ETAG , VERSION )
46
46
assert policy .etag == ETAG
47
47
assert policy .version == VERSION
48
+ assert len (policy ) == 0
49
+ assert dict (policy ) == {}
48
50
assert policy .owners == empty
49
51
assert policy .editors == empty
50
52
assert policy .viewers == empty
51
- assert len (policy ) == 0
52
- assert dict (policy ) == {}
53
53
54
54
def test___getitem___miss (self ):
55
55
policy = self ._make_one ()
56
56
assert policy ["nonesuch" ] == set ()
57
57
58
+ def test__getitem___and_set (self ):
59
+ from google .api_core .iam import OWNER_ROLE
60
+ policy = self ._make_one ()
61
+
62
+ # get the policy using the getter and then modify it
63
+ policy [
OWNER_ROLE ].
add (
"user:[email protected] " )
64
+ assert dict (
policy )
== {
OWNER_ROLE : {
"user:[email protected] " }}
65
+
58
66
def test___getitem___version3 (self ):
59
67
policy = self ._make_one ("DEADBEEF" , 3 )
60
68
with pytest .raises (InvalidOperationException , match = _DICT_ACCESS_MSG ):
@@ -293,10 +301,10 @@ def test_from_api_repr_only_etag(self):
293
301
policy = klass .from_api_repr (RESOURCE )
294
302
assert policy .etag == "ACAB"
295
303
assert policy .version is None
304
+ assert dict (policy ) == {}
296
305
assert policy .owners == empty
297
306
assert policy .editors == empty
298
307
assert policy .viewers == empty
299
- assert dict (policy ) == {}
300
308
301
309
def test_from_api_repr_complete (self ):
302
310
from google .api_core .iam import OWNER_ROLE , EDITOR_ROLE , VIEWER_ROLE
0 commit comments