Skip to content
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

add django test matrix #40

Merged
5 changes: 3 additions & 2 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.10","3.11","3.12"]
python-version: ["3.10", "3.11","3.12"]
django-version: ["3.2.9","4.1","5.1"]

steps:
- uses: actions/checkout@v3
Expand All @@ -25,7 +26,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install setuptools
python -m pip install .
python -m pip install . "Django~=${{ matrix.django-version }}"
- name: Run Tests
run: |
python ./example/manage.py test django_walletpass
7 changes: 5 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11","3.12"]
django-version: ["3.2.9","4.1","5.1"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -18,8 +20,9 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install setuptools pylint
python -m pip install .
python -m pip install . "Django~=${{ matrix.django-version }}"
- name: Analysing the code with pylint
run: |
pylint --rcfile=.pylintrc $(git ls-files '*.py')
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,16 @@ WALLETPASS_CONF = {
# Defaults to DEFAULT_FILE_STORAGE
'STORAGE_CLASS': 'my.custom.storageclass,
'UPLOAD_TO': 'passes'
'STORAGE_BACKEND': 's3storage' # Dj4.2+ only
}
```

`STORAGE_BACKEND` is the key of the django settings `STORAGES` storage config. e.g

```
STORAGES['s3storage']['BACKEND'] = 'some.s3.backend.class'
```

### Push notifications sandbox (optional)

Default: False
Expand Down
12 changes: 11 additions & 1 deletion django_walletpass/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
from collections import UserDict

import django
from django.conf import settings as django_settings
from django.test.signals import setting_changed

Expand All @@ -11,6 +13,11 @@
with open(os.path.join(FULL_BASE_DIR, 'certs', 'AppleWWDRCA.cer'), 'rb') as _ffile:
wwdrca_content = _ffile.read()

if django.VERSION < (4, 2):
STORAGE_CLASS = django_settings.DEFAULT_FILE_STORAGE
else:
STORAGE_CLASS = django_settings.STORAGES["default"]["BACKEND"]

DEFAULTS = {
'PUSH_AUTH_STRATEGY': 'legacy', # legacy or token
'TOKEN_AUTH_KEY_PATH': None,
Expand All @@ -29,7 +36,8 @@
'SERVICE_URL': None,
'WALLETPASS_PUSH_CLASS': 'django_walletpass.services.PushBackend',
'PUSH_SANDBOX': False,
'STORAGE_CLASS': django_settings.DEFAULT_FILE_STORAGE,
'STORAGE_BACKEND': None, # DJ4.2+ only
'STORAGE_CLASS': STORAGE_CLASS,
'STORAGE_HTTP_REDIRECT': False,
'UPLOAD_TO': 'passes',
}
Expand All @@ -49,6 +57,8 @@ def update_conf(self):
if 'APPLE_WWDRCA_PEM_PATH' in new:
with open(new['APPLE_WWDRCA_PEM_PATH'], 'rb') as ffile:
new['WWDRCA_PEM_CONTENT'] = ffile.read()
if 'STORAGE_BACKEND' in new:
new['STORAGE_CLASS'] = new.STORAGES[new.STORAGE_BACKEND]["BACKEND"]
alexandernst marked this conversation as resolved.
Show resolved Hide resolved

self.data.update(new)

Expand Down
2 changes: 1 addition & 1 deletion django_walletpass/tests/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,6 @@ def test_create_log(self):
created_log = Log.objects.first()
self.assertIsNotNone(created_log)
expected_timestamp = datetime.datetime.strptime(expected_timestamp_str, "%Y-%m-%d %I:%M:%S %p %z")
expected_utc_timestamp = expected_timestamp.astimezone(timezone.utc)
expected_utc_timestamp = expected_timestamp.astimezone(datetime.timezone.utc)

self.assertEqual(created_log.created_at, expected_utc_timestamp)
Loading