Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 10, 2022
1 parent d214421 commit d1235c2
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 16 deletions.
6 changes: 3 additions & 3 deletions push_notifications/api/rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def to_internal_value(self, data):
data = int(data, 16) if type(data) != int else data
except ValueError:
raise ValidationError("Device ID is not a valid hex number")
return super(HexIntegerField, self).to_internal_value(data)
return super().to_internal_value(data)

def to_representation(self, value):
return value
Expand Down Expand Up @@ -160,12 +160,12 @@ def create(self, request, *args, **kwargs):
def perform_create(self, serializer):
if self.request.user.is_authenticated:
serializer.save(user=self.request.user)
return super(DeviceViewSetMixin, self).perform_create(serializer)
return super().perform_create(serializer)

def perform_update(self, serializer):
if self.request.user.is_authenticated:
serializer.save(user=self.request.user)
return super(DeviceViewSetMixin, self).perform_update(serializer)
return super().perform_update(serializer)


class AuthorizedMixin:
Expand Down
2 changes: 1 addition & 1 deletion push_notifications/conf/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _validate_apns_certificate(self, certfile):
"""Validate the APNS certificate at startup."""

try:
with open(certfile, "r") as f:
with open(certfile) as f:
content = f.read()
check_apns_certificate(content)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions push_notifications/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, *args, **kwargs):
self.default_validators = [
RegexValidator(hex_re, _("Enter a valid hexadecimal number"), "invalid")
]
super(HexadecimalField, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def prepare_value(self, value):
# converts bigint from db to hex before it is displayed in admin
Expand Down Expand Up @@ -82,7 +82,7 @@ def db_type(self, connection):
elif "sqlite" == connection.vendor:
return "UNSIGNED BIG INT"
else:
return super(HexIntegerField, self).db_type(connection=connection)
return super().db_type(connection=connection)

def get_prep_value(self, value):
""" Return the integer value to be stored from the hex string """
Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import migrations, models

Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0002_auto_20160106_0850.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.1 on 2016-01-06 08:50
from django.db import migrations, models

Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0003_wnsdevice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-13 20:46
import django.db.models.deletion
from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0004_fcm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.6 on 2016-06-13 20:46
from django.conf import settings
from django.db import migrations, models
Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0005_applicationid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import migrations, models

Expand Down
1 change: 0 additions & 1 deletion push_notifications/migrations/0006_webpushdevice.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import migrations, models

Expand Down
4 changes: 2 additions & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def test_gcm_send_message_with_no_reg_ids(self):
reg_ids = [obj.registration_id for obj in GCMDevice.objects.all()]
send_bulk_message(reg_ids, {"message": "Hello World"}, "GCM")
p.assert_called_once_with(
[u"abc", u"abc1"], {"message": "Hello World"}, cloud_type="GCM", application_id=None
["abc", "abc1"], {"message": "Hello World"}, cloud_type="GCM", application_id=None
)

def test_fcm_send_message(self):
Expand Down Expand Up @@ -506,7 +506,7 @@ def test_fcm_send_message_with_no_reg_ids(self):
reg_ids = [obj.registration_id for obj in GCMDevice.objects.all()]
send_bulk_message(reg_ids, {"message": "Hello World"}, "FCM")
p.assert_called_once_with(
[u"abc", u"abc1"], {"message": "Hello World"}, cloud_type="FCM",
["abc", "abc1"], {"message": "Hello World"}, cloud_type="FCM",
application_id=None
)

Expand Down
4 changes: 2 additions & 2 deletions tests/test_rest_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
)


GCM_DRF_INVALID_HEX_ERROR = {"device_id": [u"Device ID is not a valid hex number"]}
GCM_DRF_OUT_OF_RANGE_ERROR = {"device_id": [u"Device ID is out of range"]}
GCM_DRF_INVALID_HEX_ERROR = {"device_id": ["Device ID is not a valid hex number"]}
GCM_DRF_OUT_OF_RANGE_ERROR = {"device_id": ["Device ID is out of range"]}


class APNSDeviceSerializerTestCase(TestCase):
Expand Down

0 comments on commit d1235c2

Please sign in to comment.