Skip to content

Some types renamed to be PEP8 compliant #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion firebase_admin/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
Notification = _messaging_utils.Notification
WebpushConfig = _messaging_utils.WebpushConfig
WebpushFCMOptions = _messaging_utils.WebpushFCMOptions
WebpushFcmOptions = _messaging_utils.WebpushFCMOptions
WebpushNotification = _messaging_utils.WebpushNotification
WebpushNotificationAction = _messaging_utils.WebpushNotificationAction

Expand Down
42 changes: 21 additions & 21 deletions firebase_admin/project_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def ios_app(app_id, app=None):
app: An App instance (optional).

Returns:
IosApp: An ``IosApp`` instance.
IOSApp: An ``IOSApp`` instance.
"""
return IosApp(app_id=app_id, service=_get_project_management_service(app))
return IOSApp(app_id=app_id, service=_get_project_management_service(app))


def list_android_apps(app=None):
Expand All @@ -83,7 +83,7 @@ def list_ios_apps(app=None):
app: An App instance (optional).

Returns:
list: a list of ``IosApp`` instances referring to each iOS app in the Firebase project.
list: a list of ``IOSApp`` instances referring to each iOS app in the Firebase project.
"""
return _get_project_management_service(app).list_ios_apps()

Expand Down Expand Up @@ -111,7 +111,7 @@ def create_ios_app(bundle_id, display_name=None, app=None):
app: An App instance (optional).

Returns:
IosApp: An ``IosApp`` instance that is a reference to the newly created app.
IOSApp: An ``IOSApp`` instance that is a reference to the newly created app.
"""
return _get_project_management_service(app).create_ios_app(bundle_id, display_name)

Expand Down Expand Up @@ -199,7 +199,7 @@ def get_sha_certificates(self):
"""Retrieves the entire list of SHA certificates associated with this Android app.

Returns:
list: A list of ``ShaCertificate`` instances.
list: A list of ``SHACertificate`` instances.

Raises:
FirebaseError: If an error occurs while communicating with the Firebase Project
Expand Down Expand Up @@ -238,7 +238,7 @@ def delete_sha_certificate(self, certificate_to_delete):
return self._service.delete_sha_certificate(certificate_to_delete)


class IosApp(object):
class IOSApp(object):
"""A reference to an iOS app within a Firebase project.

Note: Unless otherwise specified, all methods defined in this class make an RPC.
Expand Down Expand Up @@ -266,7 +266,7 @@ def get_metadata(self):
"""Retrieves detailed information about this iOS app.

Returns:
IosAppMetadata: An ``IosAppMetadata`` instance.
IOSAppMetadata: An ``IOSAppMetadata`` instance.

Raises:
FirebaseError: If an error occurs while communicating with the Firebase Project
Expand Down Expand Up @@ -359,12 +359,12 @@ def __hash__(self):
(self._name, self.app_id, self.display_name, self.project_id, self.package_name))


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

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

@property
Expand All @@ -373,7 +373,7 @@ def bundle_id(self):
return self._bundle_id

def __eq__(self, other):
return super(IosAppMetadata, self).__eq__(other) and self.bundle_id == other.bundle_id
return super(IOSAppMetadata, self).__eq__(other) and self.bundle_id == other.bundle_id

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


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

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

def __init__(self, sha_hash, name=None):
"""Creates a new ShaCertificate instance.
"""Creates a new SHACertificate instance.

Args:
sha_hash: A string; the certificate hash for the Android app.
Expand All @@ -407,10 +407,10 @@ def __init__(self, sha_hash, name=None):
_check_is_nonempty_string_or_none(name, 'name')
self._name = name
self._sha_hash = sha_hash.lower()
if ShaCertificate._SHA_1_RE.match(sha_hash):
self._cert_type = ShaCertificate.SHA_1
elif ShaCertificate._SHA_256_RE.match(sha_hash):
self._cert_type = ShaCertificate.SHA_256
if SHACertificate._SHA_1_RE.match(sha_hash):
self._cert_type = SHACertificate.SHA_1
elif SHACertificate._SHA_256_RE.match(sha_hash):
self._cert_type = SHACertificate.SHA_256
else:
raise ValueError(
'The supplied certificate hash is neither a valid SHA-1 nor SHA_256 hash.')
Expand Down Expand Up @@ -444,7 +444,7 @@ def cert_type(self):
return self._cert_type

def __eq__(self, other):
if not isinstance(other, ShaCertificate):
if not isinstance(other, SHACertificate):
return False
return (self.name == other.name and self.sha_hash == other.sha_hash and
self.cert_type == other.cert_type)
Expand Down Expand Up @@ -496,7 +496,7 @@ def get_ios_app_metadata(self, app_id):
return self._get_app_metadata(
platform_resource_name=_ProjectManagementService.IOS_APPS_RESOURCE_NAME,
identifier_name=_ProjectManagementService.IOS_APP_IDENTIFIER_NAME,
metadata_class=IosAppMetadata,
metadata_class=IOSAppMetadata,
app_id=app_id)

def _get_app_metadata(self, platform_resource_name, identifier_name, metadata_class, app_id):
Expand Down Expand Up @@ -538,7 +538,7 @@ def list_android_apps(self):
def list_ios_apps(self):
return self._list_apps(
platform_resource_name=_ProjectManagementService.IOS_APPS_RESOURCE_NAME,
app_class=IosApp)
app_class=IOSApp)

def _list_apps(self, platform_resource_name, app_class):
"""Lists all the Android or iOS apps within the Firebase project."""
Expand Down Expand Up @@ -579,7 +579,7 @@ def create_ios_app(self, bundle_id, display_name=None):
identifier_name=_ProjectManagementService.IOS_APP_IDENTIFIER_NAME,
identifier=bundle_id,
display_name=display_name,
app_class=IosApp)
app_class=IOSApp)

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

def add_sha_certificate(self, app_id, certificate_to_add):
path = '/v1beta1/projects/-/androidApps/{0}/sha'.format(app_id)
Expand Down
14 changes: 7 additions & 7 deletions integration/test_project_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
SHA_1_HASH_2 = 'aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbb'
SHA_256_HASH_1 = '123456789a123456789a123456789a123456789a123456789a123456789a1234'
SHA_256_HASH_2 = 'cafef00dba5eba11b01dfaceacc01adeda7aba5eca55e77e0b57ac1e5ca1ab1e'
SHA_1 = project_management.ShaCertificate.SHA_1
SHA_256 = project_management.ShaCertificate.SHA_256
SHA_1 = project_management.SHACertificate.SHA_1
SHA_256 = project_management.SHACertificate.SHA_256


def _starts_with(display_name, prefix):
Expand Down Expand Up @@ -120,10 +120,10 @@ def test_android_sha_certificates(android_app):
android_app.delete_sha_certificate(cert)

# Add four different certs and assert that they have all been added successfully.
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_1_HASH_1))
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_1_HASH_2))
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_1))
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_2))
android_app.add_sha_certificate(project_management.SHACertificate(SHA_1_HASH_1))
android_app.add_sha_certificate(project_management.SHACertificate(SHA_1_HASH_2))
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_1))
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_2))

cert_list = android_app.get_sha_certificates()

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

# Adding the same cert twice should cause an already-exists error.
with pytest.raises(exceptions.AlreadyExistsError) as excinfo:
android_app.add_sha_certificate(project_management.ShaCertificate(SHA_256_HASH_2))
android_app.add_sha_certificate(project_management.SHACertificate(SHA_256_HASH_2))
assert 'Requested entity already exists' in str(excinfo.value)
assert excinfo.value.cause is not None
assert excinfo.value.http_response is not None
Expand Down
19 changes: 0 additions & 19 deletions tests/test_messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,25 +566,6 @@ def test_webpush_options(self):
}
check_encoding(msg, expected)

def test_deprecated_fcm_options(self):
msg = messaging.Message(
topic='topic',
webpush=messaging.WebpushConfig(
fcm_options=messaging.WebpushFcmOptions(
link='https://example',
),
)
)
expected = {
'topic': 'topic',
'webpush': {
'fcm_options': {
'link': 'https://example',
},
},
}
check_encoding(msg, expected)


class TestWebpushNotificationEncoder(object):

Expand Down
Loading