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

Upgrade #1

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
46 changes: 46 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Django CI

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.12.0]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install coverage
pip install coveralls
pip install setuptools
pip install -r requirements.txt
- name: Run Flake8
run: |
flake8 edc_list_data
python manage.py check
- name: Run Tests
run: |
coverage run --source=edc_list_data manage.py test
coverage xml -i
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./coverage.xml
2 changes: 1 addition & 1 deletion edc_list_data/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def ready(self):
sys.stdout.write(f'Loading {self.verbose_name} ...\n')
if 'test' in sys.argv:
sys.stdout.write(style.WARNING(
f' Not updating list data for tests. '
' Not updating list data for tests. '
'Add site_list_data.autodiscover() to your test setUp.\n'))
elif 'migrate' in sys.argv or 'makemigrations' in sys.argv:
pass
Expand Down
9 changes: 5 additions & 4 deletions edc_list_data/preload_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def load_model_data(self):

Format:
{app_label.model1: [{field_name1: value, field_name2: value ...},...],
(app_label.model2, unique_field_name): [{field_name1: value, unique_field_name: value ...}, ...],
(app_label.model2, unique_field_name): [{field_name1: value,
unique_field_name: value ...}, ...],
...}
"""
for model_name, datas in self.model_data.items():
Expand All @@ -81,7 +82,7 @@ def load_model_data(self):
setattr(obj, key, value)
obj.save()

def update_unique_field_data(self):
def update_unique_field_data(self): # noqa
"""Updates the values of the unique fields in a model.

Model must have a unique field and the record must exist
Expand All @@ -96,7 +97,7 @@ def update_unique_field_data(self):
for field, values in data.items():
try:
obj = model.objects.get(**{field: values[1]})
except model.DoesNotExist as e:
except model.DoesNotExist as e: # noqa
try:
obj = model.objects.get(**{field: values[0]})
except model.DoesNotExist as e:
Expand All @@ -109,7 +110,7 @@ def update_unique_field_data(self):
else:
try:
obj = model.objects.get(**{field: values[0]})
except model.DoesNotExist as e:
except model.DoesNotExist as e: # noqa
pass
else:
try:
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Django==4.2.5
flake8==6.1.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
ignore = E226,E302,E41,F401,W503
max-line-length = 95
max-line-length = 100
max-complexity = 10
# exclude =