2121
2222
2323def test_blob_to_proto_simple_fields ():
24- blob = mock .Mock (spec = ["name" , "bucket" , "content_type" , "metadata" , "kms_key_name" , "cache_control" , "content_disposition" , "content_encoding" , "content_language" , "temporary_hold" , "event_based_hold" , "custom_time" , "acl" , "retention" , "contexts" ])
24+ blob = mock .Mock (
25+ spec = [
26+ "name" ,
27+ "bucket" ,
28+ "content_type" ,
29+ "metadata" ,
30+ "kms_key_name" ,
31+ "cache_control" ,
32+ "content_disposition" ,
33+ "content_encoding" ,
34+ "content_language" ,
35+ "temporary_hold" ,
36+ "event_based_hold" ,
37+ "custom_time" ,
38+ "acl" ,
39+ "retention" ,
40+ ]
41+ )
2542 blob .name = "blob-name"
2643 blob .bucket .name = "bucket-name"
2744 blob .content_type = "text/plain"
@@ -36,7 +53,6 @@ def test_blob_to_proto_simple_fields():
3653 blob .custom_time = None
3754 blob .acl = None
3855 blob .retention = None
39- blob .contexts = None
4056
4157 proto = _grpc_conversions .blob_to_proto (blob )
4258
@@ -54,13 +70,14 @@ def test_blob_to_proto_simple_fields():
5470
5571
5672def test_blob_to_proto_custom_time ():
57- blob = mock .Mock (spec = ["name" , "bucket" , "custom_time" , "acl" , "retention" , "contexts" ])
73+ blob = mock .Mock (spec = ["name" , "bucket" , "custom_time" , "acl" , "retention" ])
5874 blob .name = "blob-name"
5975 blob .bucket .name = "bucket-name"
60- blob .custom_time = datetime .datetime (2025 , 1 , 1 , 12 , 0 , 0 , tzinfo = datetime .timezone .utc )
76+ blob .custom_time = datetime .datetime (
77+ 2025 , 1 , 1 , 12 , 0 , 0 , tzinfo = datetime .timezone .utc
78+ )
6179 blob .acl = None
6280 blob .retention = None
63- blob .contexts = None
6481 # ensure other fields don't cause issues if missing
6582 for attr in _grpc_conversions ._BLOB_ATTR_TO_PROTO_FIELD :
6683 setattr (blob , attr , None )
@@ -71,21 +88,22 @@ def test_blob_to_proto_custom_time():
7188
7289
7390def test_blob_to_proto_acl ():
74- blob = mock .Mock (spec = ["name" , "bucket" , "acl" , "custom_time" , "retention" , "contexts" ])
91+ blob = mock .Mock (spec = ["name" , "bucket" , "acl" , "custom_time" , "retention" ])
7592 blob .name = "blob-name"
7693 blob .bucket .name = "bucket-name"
7794
7895 acl_mock = mock .MagicMock ()
7996 acl_mock .loaded = True
80- acl_mock .__iter__ .return_value = iter ([
81- {"role" : "READER" , "entity" : "allUsers" },
82- {"role" : "OWNER" , "entity" : "user-123" },
83- ])
97+ acl_mock .__iter__ .return_value = iter (
98+ [
99+ {"role" : "READER" , "entity" : "allUsers" },
100+ {"role" : "OWNER" , "entity" : "user-123" },
101+ ]
102+ )
84103 blob .acl = acl_mock
85104
86105 blob .custom_time = None
87106 blob .retention = None
88- blob .contexts = None
89107 for attr in _grpc_conversions ._BLOB_ATTR_TO_PROTO_FIELD :
90108 setattr (blob , attr , None )
91109
@@ -98,42 +116,22 @@ def test_blob_to_proto_acl():
98116 assert proto .acl [1 ].entity == "user-123"
99117
100118
101- def test_blob_to_proto_contexts ():
102- blob = mock .Mock (spec = ["name" , "bucket" , "contexts" , "custom_time" , "acl" , "retention" ])
103- blob .name = "blob-name"
104- blob .bucket .name = "bucket-name"
105- blob .contexts = {"c1" : "v1" , "c2" : "v2" }
106- blob .custom_time = None
107- blob .acl = None
108- blob .retention = None
109- for attr in _grpc_conversions ._BLOB_ATTR_TO_PROTO_FIELD :
110- setattr (blob , attr , None )
111-
112- proto = _grpc_conversions .blob_to_proto (blob )
113-
114- assert len (proto .contexts .custom ) == 2
115- contexts_dict = {k : v .value for k , v in proto .contexts .custom .items ()}
116- assert contexts_dict == {"c1" : "v1" , "c2" : "v2" }
117-
118-
119119def test_blob_to_proto_retention ():
120- blob = mock .Mock (spec = ["name" , "bucket" , "retention" , "custom_time" , "acl" , "contexts" ])
120+ blob = mock .Mock (spec = ["name" , "bucket" , "retention" , "custom_time" , "acl" ])
121121 blob .name = "blob-name"
122122 blob .bucket .name = "bucket-name"
123123
124124 retain_until_time = datetime .datetime (2026 , 1 , 1 , tzinfo = datetime .timezone .utc )
125- blob .retention = {
126- "mode" : "Locked" ,
127- "retain_until_time" : retain_until_time
128- }
125+ blob .retention = {"mode" : "Locked" , "retain_until_time" : retain_until_time }
129126
130127 blob .custom_time = None
131128 blob .acl = None
132- blob .contexts = None
133129 for attr in _grpc_conversions ._BLOB_ATTR_TO_PROTO_FIELD :
134130 setattr (blob , attr , None )
135131
136132 proto = _grpc_conversions .blob_to_proto (blob )
137133
138134 assert proto .retention .mode == _storage_v2 .Object .Retention .Mode .LOCKED
139- assert int (proto .retention .retain_until_time .timestamp ()) == int (retain_until_time .timestamp ())
135+ assert int (proto .retention .retain_until_time .timestamp ()) == int (
136+ retain_until_time .timestamp ()
137+ )
0 commit comments