Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
jamaalscarlett committed Aug 16, 2023
2 parents 7582fa0 + 53525ca commit 5517542
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
jobs:
build:
if: github.repository == 'jazzband/django-push-notifications'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -37,6 +37,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox tox-gh-actions
python -m pip install setuptools-scm==6.4.2
- name: Tox tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion push_notifications/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
UNSIGNED_64BIT_INT_MAX_VALUE = 2 ** 64 - 1


hex_re = re.compile(r"^(([0-9A-f])|(0x[0-9A-f]))+$")
hex_re = re.compile(r"^(0x)?([0-9a-f])+$", re.I)
signed_integer_vendors = [
"postgresql",
"sqlite",
Expand Down
40 changes: 40 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase

from push_notifications.fields import HexadecimalField


class HexadecimalFieldTestCase(SimpleTestCase):
_INVALID_HEX_VALUES = [
"foobar",
"GLUTEN",
"HeLLo WoRLd",
"international",
"°!#€%&/()[]{}=?",
"0x",
]

_VALID_HEX_VALUES = {
"babe": "babe",
"BEEF": "BEEF",
" \nfeed \t": "feed",
"0x012345789abcdef": "0x012345789abcdef",
"012345789aBcDeF": "012345789aBcDeF",
}

def test_clean_invalid_values(self):
"""Passing invalid values raises ValidationError."""
f = HexadecimalField()
for invalid in self._INVALID_HEX_VALUES:
self.assertRaisesMessage(
ValidationError,
"'Enter a valid hexadecimal number'",
f.clean,
invalid,
)

def test_clean_valid_values(self):
"""Passing valid values returns the expected output."""
f = HexadecimalField()
for valid, expected in self._VALID_HEX_VALUES.items():
self.assertEqual(expected, f.clean(valid))
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
skipsdist = True
skipsdist = False
usedevelop = true
envlist =
py{36,37,38,39}-dj{22,32}
Expand Down

0 comments on commit 5517542

Please sign in to comment.