Skip to content

Commit

Permalink
Merge branch 'release/0.3.85'
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWillitts committed Sep 18, 2024
2 parents 3211d89 + bc330d4 commit 2713419
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 68 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ on: [push, pull_request]

jobs:
build:
name: build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }})
name: |
build (Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}, ${{ matrix.database-engine }})
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12']
django-version: ['4.2', '5.0', 'dev']
python-version: ['3.12']
django-version: ['4.2', '5.1', 'dev']
database-engine: ["mysql", "postgres"]

exclude:
- python-version: '3.12'
django-version: '4.2'
- python-version: '3.11'
django-version: 'dev'
services:
mysql:
image: mysql:latest
Expand All @@ -28,6 +25,17 @@ jobs:
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
postgres:
image: postgres:latest
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Install pycups and words dependency
Expand Down Expand Up @@ -61,7 +69,6 @@ jobs:
python -m pip install --upgrade pip
python -m pip install -r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/tox.txt
- name: Tox tests
run: |
tox -v
Expand Down
28 changes: 17 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ exclude: tests/etc/user-*

repos:
- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
rev: 1.7.9
hooks:
- id: bandit
args:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 24.8.0
hooks:
- id: black
language_version: python3.11
language_version: python3.12

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
args:
Expand All @@ -28,21 +28,27 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: requirements-txt-fixer
files: requirements/.*\.txt$
- id: trailing-whitespace
- id: check-added-large-files
- id: fix-byte-order-marker
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
# - id: detect-private-key
- id: detect-private-key
exclude: |
(?x)^(
edc_consent/tests/crypto_keys/user-rsa-local-private.pem|
edc_consent/tests/crypto_keys/user-rsa-restricted-private.pem
)$
- id: fix-byte-order-marker
- id: requirements-txt-fixer
files: requirements/.*\.txt$
- id: trailing-whitespace

- repo: https://github.com/adrienverge/yamllint
rev: v1.34.0
rev: v1.35.1
hooks:
- id: yamllint
args:
Expand Down
13 changes: 9 additions & 4 deletions edc_consent/consent_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,21 @@ def check_date_within_study_period(self) -> None:
protocol = ResearchProtocolConfig()
study_open_datetime = protocol.study_open_datetime
study_close_datetime = protocol.study_close_datetime
for index, attr in enumerate(["start", "end"]):
for attr in ["start", "end"]:
if not (
floor_secs(study_open_datetime)
<= getattr(self, attr)
<= ceil_secs(study_close_datetime)
):
date_string = formatted_datetime(getattr(self, attr))
open_date_string = formatted_datetime(study_open_datetime)
close_date_string = formatted_datetime(study_close_datetime)
attr_date_string = formatted_datetime(getattr(self, attr))
raise ConsentDefinitionError(
f"Invalid {attr} date. Cannot be before study start date. "
f"See {self}. Got {date_string}."
f"Invalid {attr} date. "
f"Must be within the opening and closing dates of the protocol. "
f"See {self}. "
f"Got {open_date_string=}, {close_date_string=}, "
f"{attr=}, {attr_date_string=}."
)

def get_previous_consent(
Expand Down
31 changes: 15 additions & 16 deletions edc_consent/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python
import sys
from pathlib import Path

Expand All @@ -6,13 +7,11 @@
from edc_utils import get_utcnow

app_name = "edc_consent"
base_dir = Path(__file__).absolute().parent
base_dir = Path(__file__).absolute().parent.parent.parent

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
DJANGO_CRYPTO_FIELDS_KEY_PATH=base_dir / "crypto_keys",
GIT_DIR=base_dir.parent.parent,
APP_NAME=app_name,
SILENCED_SYSTEM_CHECKS=[
"edc_consent.E001",
Expand All @@ -21,17 +20,16 @@
"edc_navbar.E003",
"edc_sites.E001",
],
ETC_DIR=str(base_dir / app_name / "tests" / "etc"),
EDC_NAVBAR_DEFAULT="edc_consent",
EDC_PROTOCOL_STUDY_OPEN_DATETIME=get_utcnow() - relativedelta(years=1),
EDC_PROTOCOL_STUDY_CLOSE_DATETIME=get_utcnow() + relativedelta(years=1),
EDC_SITES_REGISTER_DEFAULT=True,
SUBJECT_SCREENING_MODEL="consent_app.subjectscreening",
SUBJECT_CONSENT_MODEL="consent_app.subjectconsent",
SUBJECT_VISIT_MODEL="consent_app.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="consent_app.subjectvisitmissed",
SUBJECT_REQUISITION_MODEL="consent_app.subjectrequisition",
SUBJECT_REFUSAL_MODEL="consent_app.subjectrefusal",
EDC_SITES_REGISTER_DEFAULT=True,
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
Expand All @@ -40,30 +38,31 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"multisite",
"simple_history",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"multisite",
"adverse_event_app.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_adverse_event.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_export.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_crf.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_locator.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_protocol.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_consent.apps.AppConfig",
"edc_auth.apps.AppConfig",
"consent_app.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
Expand Down
14 changes: 6 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ version_file="_version.py"

[tool.black]
line-length = 95
target-version = ["py311"]
target-version = ["py312"]
extend-exclude = '''^(.*\/)*\b(migrations)\b($|\/.*$)'''

[tool.isort]
profile = "black"
py_version = "311"
py_version = "312"
skip = [".tox", ".eggs", "migrations"]

[tool.coverage.run]
Expand All @@ -35,21 +35,19 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
envlist =
py{311}-dj{42,50},
py{312}-dj{50,dev},
py{312}-dj{42,51,dev},
lint
isolated_build = true
[gh-actions]
python =
3.11: py311
3.12: py312, lint
[gh-actions:env]
DJANGO =
4.2: dj42
5.0: dj50
5.1: dj51
dev: djdev, lint
[testenv]
Expand All @@ -59,11 +57,11 @@ deps =
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/edc.txt
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/third_party_dev.txt
dj42: Django>=4.2,<5.0
dj50: Django>=5.0
dj51: Django>=5.1,<5.2
djdev: https://github.com/django/django/tarball/main
commands =
pip install -U pip coverage[toml]
pip install -U pip
pip --version
pip freeze
coverage run -a runtests.py
Expand Down
19 changes: 2 additions & 17 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-


import os
import sys
from edc_test_settings.func_main import func_main2

if __name__ == "__main__":
os.environ["DJANGO_SETTINGS_MODULE"] = "edc_consent.tests.test_settings"
import django

django.setup()
from django.test.runner import DiscoverRunner

tags = [t.split("=")[1] for t in sys.argv if t.startswith("--tag")]
failfast = any([True for t in sys.argv if t.startswith("--failfast")])
keepdb = any([True for t in sys.argv if t.startswith("--keepdb")])
opts = dict(failfast=failfast, tags=tags, keepdb=keepdb)
failures = DiscoverRunner(**opts).run_tests(["edc_consent.tests"], **opts)
sys.exit(failures)
func_main2("edc_consent.tests.test_settings", "edc_consent.tests")
6 changes: 3 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ classifiers=
Environment :: Web Environment
Framework :: Django
Framework :: Django :: 4.2
Framework :: Django :: 5.1
Intended Audience :: Developers
Intended Audience :: Science/Research
Operating System :: OS Independent
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
License :: OSI Approved :: GNU General Public License v3 (GPLv3)


[options]
python_requires = >=3.11
python_requires = >=3.12
zip_safe = False
include_package_data = True
packages = find:
Expand Down

0 comments on commit 2713419

Please sign in to comment.