Skip to content

Commit ff28261

Browse files
authored
Some types renamed to be PEP8 compliant (#330)
1 parent cfff7d4 commit ff28261

File tree

5 files changed

+70
-90
lines changed

5 files changed

+70
-90
lines changed

firebase_admin/messaging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
Notification = _messaging_utils.Notification
8282
WebpushConfig = _messaging_utils.WebpushConfig
8383
WebpushFCMOptions = _messaging_utils.WebpushFCMOptions
84-
WebpushFcmOptions = _messaging_utils.WebpushFCMOptions
8584
WebpushNotification = _messaging_utils.WebpushNotification
8685
WebpushNotificationAction = _messaging_utils.WebpushNotificationAction
8786

firebase_admin/project_management.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ def ios_app(app_id, app=None):
5858
app: An App instance (optional).
5959
6060
Returns:
61-
IosApp: An ``IosApp`` instance.
61+
IOSApp: An ``IOSApp`` instance.
6262
"""
63-
return IosApp(app_id=app_id, service=_get_project_management_service(app))
63+
return IOSApp(app_id=app_id, service=_get_project_management_service(app))
6464

6565

6666
def list_android_apps(app=None):
@@ -83,7 +83,7 @@ def list_ios_apps(app=None):
8383
app: An App instance (optional).
8484
8585
Returns:
86-
list: a list of ``IosApp`` instances referring to each iOS app in the Firebase project.
86+
list: a list of ``IOSApp`` instances referring to each iOS app in the Firebase project.
8787
"""
8888
return _get_project_management_service(app).list_ios_apps()
8989

@@ -111,7 +111,7 @@ def create_ios_app(bundle_id, display_name=None, app=None):
111111
app: An App instance (optional).
112112
113113
Returns:
114-
IosApp: An ``IosApp`` instance that is a reference to the newly created app.
114+
IOSApp: An ``IOSApp`` instance that is a reference to the newly created app.
115115
"""
116116
return _get_project_management_service(app).create_ios_app(bundle_id, display_name)
117117

@@ -199,7 +199,7 @@ def get_sha_certificates(self):
199199
"""Retrieves the entire list of SHA certificates associated with this Android app.
200200
201201
Returns:
202-
list: A list of ``ShaCertificate`` instances.
202+
list: A list of ``SHACertificate`` instances.
203203
204204
Raises:
205205
FirebaseError: If an error occurs while communicating with the Firebase Project
@@ -238,7 +238,7 @@ def delete_sha_certificate(self, certificate_to_delete):
238238
return self._service.delete_sha_certificate(certificate_to_delete)
239239

240240

241-
class IosApp(object):
241+
class IOSApp(object):
242242
"""A reference to an iOS app within a Firebase project.
243243
244244
Note: Unless otherwise specified, all methods defined in this class make an RPC.
@@ -266,7 +266,7 @@ def get_metadata(self):
266266
"""Retrieves detailed information about this iOS app.
267267
268268
Returns:
269-
IosAppMetadata: An ``IosAppMetadata`` instance.
269+
IOSAppMetadata: An ``IOSAppMetadata`` instance.
270270
271271
Raises:
272272
FirebaseError: If an error occurs while communicating with the Firebase Project
@@ -359,12 +359,12 @@ def __hash__(self):
359359
(self._name, self.app_id, self.display_name, self.project_id, self.package_name))
360360

361361

362-
class IosAppMetadata(_AppMetadata):
362+
class IOSAppMetadata(_AppMetadata):
363363
"""iOS-specific information about an iOS Firebase app."""
364364

365365
def __init__(self, bundle_id, name, app_id, display_name, project_id):
366366
"""Clients should not instantiate this class directly."""
367-
super(IosAppMetadata, self).__init__(name, app_id, display_name, project_id)
367+
super(IOSAppMetadata, self).__init__(name, app_id, display_name, project_id)
368368
self._bundle_id = _check_is_nonempty_string(bundle_id, 'bundle_id')
369369

370370
@property
@@ -373,7 +373,7 @@ def bundle_id(self):
373373
return self._bundle_id
374374

375375
def __eq__(self, other):
376-
return super(IosAppMetadata, self).__eq__(other) and self.bundle_id == other.bundle_id
376+
return super(IOSAppMetadata, self).__eq__(other) and self.bundle_id == other.bundle_id
377377

378378
def __ne__(self, other):
379379
return not self.__eq__(other)
@@ -382,7 +382,7 @@ def __hash__(self):
382382
return hash((self._name, self.app_id, self.display_name, self.project_id, self.bundle_id))
383383

384384

385-
class ShaCertificate(object):
385+
class SHACertificate(object):
386386
"""Represents a SHA-1 or SHA-256 certificate associated with an Android app."""
387387

388388
SHA_1 = 'SHA_1'
@@ -392,7 +392,7 @@ class ShaCertificate(object):
392392
_SHA_256_RE = re.compile('^[0-9A-Fa-f]{64}$')
393393

394394
def __init__(self, sha_hash, name=None):
395-
"""Creates a new ShaCertificate instance.
395+
"""Creates a new SHACertificate instance.
396396
397397
Args:
398398
sha_hash: A string; the certificate hash for the Android app.
@@ -407,10 +407,10 @@ def __init__(self, sha_hash, name=None):
407407
_check_is_nonempty_string_or_none(name, 'name')
408408
self._name = name
409409
self._sha_hash = sha_hash.lower()
410-
if ShaCertificate._SHA_1_RE.match(sha_hash):
411-
self._cert_type = ShaCertificate.SHA_1
412-
elif ShaCertificate._SHA_256_RE.match(sha_hash):
413-
self._cert_type = ShaCertificate.SHA_256
410+
if SHACertificate._SHA_1_RE.match(sha_hash):
411+
self._cert_type = SHACertificate.SHA_1
412+
elif SHACertificate._SHA_256_RE.match(sha_hash):
413+
self._cert_type = SHACertificate.SHA_256
414414
else:
415415
raise ValueError(
416416
'The supplied certificate hash is neither a valid SHA-1 nor SHA_256 hash.')
@@ -444,7 +444,7 @@ def cert_type(self):
444444
return self._cert_type
445445

446446
def __eq__(self, other):
447-
if not isinstance(other, ShaCertificate):
447+
if not isinstance(other, SHACertificate):
448448
return False
449449
return (self.name == other.name and self.sha_hash == other.sha_hash and
450450
self.cert_type == other.cert_type)
@@ -496,7 +496,7 @@ def get_ios_app_metadata(self, app_id):
496496
return self._get_app_metadata(
497497
platform_resource_name=_ProjectManagementService.IOS_APPS_RESOURCE_NAME,
498498
identifier_name=_ProjectManagementService.IOS_APP_IDENTIFIER_NAME,
499-
metadata_class=IosAppMetadata,
499+
metadata_class=IOSAppMetadata,
500500
app_id=app_id)
501501

502502
def _get_app_metadata(self, platform_resource_name, identifier_name, metadata_class, app_id):
@@ -538,7 +538,7 @@ def list_android_apps(self):
538538
def list_ios_apps(self):
539539
return self._list_apps(
540540
platform_resource_name=_ProjectManagementService.IOS_APPS_RESOURCE_NAME,
541-
app_class=IosApp)
541+
app_class=IOSApp)
542542

543543
def _list_apps(self, platform_resource_name, app_class):
544544
"""Lists all the Android or iOS apps within the Firebase project."""
@@ -579,7 +579,7 @@ def create_ios_app(self, bundle_id, display_name=None):
579579
identifier_name=_ProjectManagementService.IOS_APP_IDENTIFIER_NAME,
580580
identifier=bundle_id,
581581
display_name=display_name,
582-
app_class=IosApp)
582+
app_class=IOSApp)
583583

584584
def _create_app(
585585
self,
@@ -639,7 +639,7 @@ def get_sha_certificates(self, app_id):
639639
path = '/v1beta1/projects/-/androidApps/{0}/sha'.format(app_id)
640640
response = self._make_request('get', path)
641641
cert_list = response.get('certificates') or []
642-
return [ShaCertificate(sha_hash=cert['shaHash'], name=cert['name']) for cert in cert_list]
642+
return [SHACertificate(sha_hash=cert['shaHash'], name=cert['name']) for cert in cert_list]
643643

644644
def add_sha_certificate(self, app_id, certificate_to_add):
645645
path = '/v1beta1/projects/-/androidApps/{0}/sha'.format(app_id)

integration/test_project_management.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
SHA_1_HASH_2 = 'aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb'
3333
SHA_256_HASH_1 = '123456789a123456789a123456789a123456789a123456789a123456789a1234'
3434
SHA_256_HASH_2 = 'cafef00dba5eba11b01dfaceacc01adeda7aba5eca55e77e0b57ac1e5ca1ab1e'
35-
SHA_1 = project_management.ShaCertificate.SHA_1
36-
SHA_256 = project_management.ShaCertificate.SHA_256
35+
SHA_1 = project_management.SHACertificate.SHA_1
36+
SHA_256 = project_management.SHACertificate.SHA_256
3737

3838

3939
def _starts_with(display_name, prefix):
@@ -120,10 +120,10 @@ def test_android_sha_certificates(android_app):
120120
android_app.delete_sha_certificate(cert)
121121

122122
# Add four different certs and assert that they have all been added successfully.
123-
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_1_HASH_1))
124-
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_1_HASH_2))
125-
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_1))
126-
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_2))
123+
android_app.add_sha_certificate(project_management.SHACertificate(SHA_1_HASH_1))
124+
android_app.add_sha_certificate(project_management.SHACertificate(SHA_1_HASH_2))
125+
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_1))
126+
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_2))
127127

128128
cert_list = android_app.get_sha_certificates()
129129

@@ -136,7 +136,7 @@ def test_android_sha_certificates(android_app):
136136

137137
# Adding the same cert twice should cause an already-exists error.
138138
with pytest.raises(exceptions.AlreadyExistsError) as excinfo:
139-
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_2))
139+
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_2))
140140
assert 'Requested entity already exists' in str(excinfo.value)
141141
assert excinfo.value.cause is not None
142142
assert excinfo.value.http_response is not None

tests/test_messaging.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -566,25 +566,6 @@ def test_webpush_options(self):
566566
}
567567
check_encoding(msg, expected)
568568

569-
def test_deprecated_fcm_options(self):
570-
msg = messaging.Message(
571-
topic='topic',
572-
webpush=messaging.WebpushConfig(
573-
fcm_options=messaging.WebpushFcmOptions(
574-
link='https://example',
575-
),
576-
)
577-
)
578-
expected = {
579-
'topic': 'topic',
580-
'webpush': {
581-
'fcm_options': {
582-
'link': 'https://example',
583-
},
584-
},
585-
}
586-
check_encoding(msg, expected)
587-
588569

589570
class TestWebpushNotificationEncoder(object):
590571

0 commit comments

Comments
 (0)