Skip to content

Commit 1fbee03

Browse files
authored
fix: undprecate entity factory helpers (#101)
Closes #100
1 parent d368c4b commit 1fbee03

File tree

2 files changed

+6
-75
lines changed

2 files changed

+6
-75
lines changed

google/api_core/iam.py

-33
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@
7474
_ASSIGNMENT_DEPRECATED_MSG = """\
7575
Assigning to '{}' is deprecated. Use the `policy.bindings` property to modify bindings instead."""
7676

77-
_FACTORY_DEPRECATED_MSG = """\
78-
Factory method {0} is deprecated. Replace with '{0}'."""
79-
8077
_DICT_ACCESS_MSG = """\
8178
Dict access is not supported on policies with version > 1 or with conditional bindings."""
8279

@@ -323,12 +320,7 @@ def user(email):
323320
324321
Returns:
325322
str: A member string corresponding to the given user.
326-
327-
DEPRECATED: set the role `user:{email}` in the binding instead.
328323
"""
329-
warnings.warn(
330-
_FACTORY_DEPRECATED_MSG.format("user:{email}"), DeprecationWarning,
331-
)
332324
return "user:%s" % (email,)
333325

334326
@staticmethod
@@ -341,12 +333,7 @@ def service_account(email):
341333
Returns:
342334
str: A member string corresponding to the given service account.
343335
344-
DEPRECATED: set the role `serviceAccount:{email}` in the binding instead.
345336
"""
346-
warnings.warn(
347-
_FACTORY_DEPRECATED_MSG.format("serviceAccount:{email}"),
348-
DeprecationWarning,
349-
)
350337
return "serviceAccount:%s" % (email,)
351338

352339
@staticmethod
@@ -358,12 +345,7 @@ def group(email):
358345
359346
Returns:
360347
str: A member string corresponding to the given group.
361-
362-
DEPRECATED: set the role `group:{email}` in the binding instead.
363348
"""
364-
warnings.warn(
365-
_FACTORY_DEPRECATED_MSG.format("group:{email}"), DeprecationWarning,
366-
)
367349
return "group:%s" % (email,)
368350

369351
@staticmethod
@@ -375,12 +357,7 @@ def domain(domain):
375357
376358
Returns:
377359
str: A member string corresponding to the given domain.
378-
379-
DEPRECATED: set the role `domain:{email}` in the binding instead.
380360
"""
381-
warnings.warn(
382-
_FACTORY_DEPRECATED_MSG.format("domain:{email}"), DeprecationWarning,
383-
)
384361
return "domain:%s" % (domain,)
385362

386363
@staticmethod
@@ -389,12 +366,7 @@ def all_users():
389366
390367
Returns:
391368
str: A member string representing all users.
392-
393-
DEPRECATED: set the role `allUsers` in the binding instead.
394369
"""
395-
warnings.warn(
396-
_FACTORY_DEPRECATED_MSG.format("allUsers"), DeprecationWarning,
397-
)
398370
return "allUsers"
399371

400372
@staticmethod
@@ -403,12 +375,7 @@ def authenticated_users():
403375
404376
Returns:
405377
str: A member string representing all authenticated users.
406-
407-
DEPRECATED: set the role `allAuthenticatedUsers` in the binding instead.
408378
"""
409-
warnings.warn(
410-
_FACTORY_DEPRECATED_MSG.format("allAuthenticatedUsers"), DeprecationWarning,
411-
)
412379
return "allAuthenticatedUsers"
413380

414381
@classmethod

tests/unit/test_iam.py

+6-42
Original file line numberDiff line numberDiff line change
@@ -230,72 +230,36 @@ def test_viewers_setter(self):
230230
assert policy[VIEWER_ROLE] == expected
231231

232232
def test_user(self):
233-
import warnings
234-
235233
236234
MEMBER = "user:%s" % (EMAIL,)
237235
policy = self._make_one()
238-
with warnings.catch_warnings(record=True) as warned:
239-
assert policy.user(EMAIL) == MEMBER
240-
241-
(warning,) = warned
242-
assert warning.category is DeprecationWarning
236+
assert policy.user(EMAIL) == MEMBER
243237

244238
def test_service_account(self):
245-
import warnings
246-
247239
248240
MEMBER = "serviceAccount:%s" % (EMAIL,)
249241
policy = self._make_one()
250-
with warnings.catch_warnings(record=True) as warned:
251-
assert policy.service_account(EMAIL) == MEMBER
252-
253-
(warning,) = warned
254-
assert warning.category is DeprecationWarning
242+
assert policy.service_account(EMAIL) == MEMBER
255243

256244
def test_group(self):
257-
import warnings
258-
259245
260246
MEMBER = "group:%s" % (EMAIL,)
261247
policy = self._make_one()
262-
with warnings.catch_warnings(record=True) as warned:
263-
assert policy.group(EMAIL) == MEMBER
264-
265-
(warning,) = warned
266-
assert warning.category is DeprecationWarning
248+
assert policy.group(EMAIL) == MEMBER
267249

268250
def test_domain(self):
269-
import warnings
270-
271251
DOMAIN = "example.com"
272252
MEMBER = "domain:%s" % (DOMAIN,)
273253
policy = self._make_one()
274-
with warnings.catch_warnings(record=True) as warned:
275-
assert policy.domain(DOMAIN) == MEMBER
276-
277-
(warning,) = warned
278-
assert warning.category is DeprecationWarning
254+
assert policy.domain(DOMAIN) == MEMBER
279255

280256
def test_all_users(self):
281-
import warnings
282-
283257
policy = self._make_one()
284-
with warnings.catch_warnings(record=True) as warned:
285-
assert policy.all_users() == "allUsers"
286-
287-
(warning,) = warned
288-
assert warning.category is DeprecationWarning
258+
assert policy.all_users() == "allUsers"
289259

290260
def test_authenticated_users(self):
291-
import warnings
292-
293261
policy = self._make_one()
294-
with warnings.catch_warnings(record=True) as warned:
295-
assert policy.authenticated_users() == "allAuthenticatedUsers"
296-
297-
(warning,) = warned
298-
assert warning.category is DeprecationWarning
262+
assert policy.authenticated_users() == "allAuthenticatedUsers"
299263

300264
def test_from_api_repr_only_etag(self):
301265
empty = frozenset()

0 commit comments

Comments
 (0)