diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59f4d55..dd67298 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a32918b..78a9907 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: @@ -28,21 +28,22 @@ 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: 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: diff --git a/edc_lab/tests/test_settings.py b/edc_lab/tests/test_settings.py new file mode 100644 index 0000000..0a85b7b --- /dev/null +++ b/edc_lab/tests/test_settings.py @@ -0,0 +1,76 @@ +#!/usr/bin/env python +import sys +from pathlib import Path + +from edc_test_settings.default_test_settings import DefaultTestSettings + +app_name = "edc_lab" +base_dir = Path(__file__).absolute().parent.parent.parent + +project_settings = DefaultTestSettings( + calling_file=__file__, + BASE_DIR=base_dir, + APP_NAME=app_name, + ETC_DIR=str(base_dir / app_name / "tests" / "etc"), + SILENCED_SYSTEM_CHECKS=[ + "sites.E101", + "edc_navbar.E002", + "edc_navbar.E003", + "edc_consent.E001", + ], + SUBJECT_SCREENING_MODEL="lab_app.subjectscreening", + SUBJECT_CONSENT_MODEL="lab_app.subjectconsent", + SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit", + SUBJECT_VISIT_MISSED_MODEL="edc_visit_tracking.subjectvisitmissed", + SUBJECT_REQUISITION_MODEL="lab_app.subjectrequisition", + SUBJECT_APP_LABEL="lab_app", + INSTALLED_APPS=[ + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django.contrib.sites", + "django_crypto_fields.apps.AppConfig", + "django_revision.apps.AppConfig", + "multisite", + "edc_auth.apps.AppConfig", + "edc_action_item.apps.AppConfig", + "edc_appointment.apps.AppConfig", + "edc_adverse_event.apps.AppConfig", + "adverse_event_app.apps.AppConfig", + "edc_consent.apps.AppConfig", + "edc_crf.apps.AppConfig", + "edc_list_data.apps.AppConfig", + "edc_protocol.apps.AppConfig", + "edc_metadata.apps.AppConfig", + "edc_dashboard.apps.AppConfig", + "edc_subject_dashboard.apps.AppConfig", + "edc_review_dashboard.apps.AppConfig", + "edc_device.apps.AppConfig", + "edc_identifier.apps.AppConfig", + "edc_facility.apps.AppConfig", + "edc_label.apps.AppConfig", + "edc_model.apps.AppConfig", + "edc_notification.apps.AppConfig", + "edc_data_manager.apps.AppConfig", + "edc_form_runners.apps.AppConfig", + "edc_registration.apps.AppConfig", + "edc_search.apps.AppConfig", + "edc_sites.apps.AppConfig", + "edc_timepoint.apps.AppConfig", + "edc_visit_schedule.apps.AppConfig", + "edc_visit_tracking.apps.AppConfig", + "edc_offstudy.apps.AppConfig", + "edc_lab.apps.AppConfig", + "lab_app.apps.AppConfig", + "edc_appconfig.apps.AppConfig", + ], + add_dashboard_middleware=True, + use_test_urls=True, +).settings + + +for k, v in project_settings.items(): + setattr(sys.modules[__name__], k, v) diff --git a/lab_app/reference_model_configs.py b/lab_app/reference_model_configs.py deleted file mode 100644 index 779f7b3..0000000 --- a/lab_app/reference_model_configs.py +++ /dev/null @@ -1,5 +0,0 @@ -from edc_reference import site_reference_configs - -site_reference_configs.register_from_visit_schedule( - visit_models={"edc_appointment.appointment": "lab_app.subjectvisit"} -) diff --git a/pyproject.toml b/pyproject.toml index 2e2d5a7..a4915a2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] @@ -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] @@ -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 diff --git a/runtests.py b/runtests.py index 676f4d6..3131113 100644 --- a/runtests.py +++ b/runtests.py @@ -1,76 +1,5 @@ #!/usr/bin/env python -import logging -from pathlib import Path - -from edc_test_utils import DefaultTestSettings, func_main - -app_name = "edc_lab" -base_dir = Path(__file__).absolute().parent - -project_settings = DefaultTestSettings( - calling_file=__file__, - BASE_DIR=base_dir, - APP_NAME=app_name, - ETC_DIR=str(base_dir / app_name / "tests" / "etc"), - SILENCED_SYSTEM_CHECKS=[ - "sites.E101", - "edc_navbar.E002", - "edc_navbar.E003", - "edc_consent.E001", - ], - SUBJECT_SCREENING_MODEL="lab_app.subjectscreening", - SUBJECT_CONSENT_MODEL="lab_app.subjectconsent", - SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit", - SUBJECT_VISIT_MISSED_MODEL="edc_visit_tracking.subjectvisitmissed", - SUBJECT_REQUISITION_MODEL="lab_app.subjectrequisition", - SUBJECT_APP_LABEL="lab_app", - INSTALLED_APPS=[ - "django.contrib.admin", - "django.contrib.auth", - "django.contrib.contenttypes", - "django.contrib.sessions", - "django.contrib.messages", - "django.contrib.staticfiles", - "django.contrib.sites", - "django_crypto_fields.apps.AppConfig", - "django_revision.apps.AppConfig", - "multisite", - "edc_auth.apps.AppConfig", - "edc_action_item.apps.AppConfig", - "edc_appointment.apps.AppConfig", - "edc_consent.apps.AppConfig", - "edc_crf.apps.AppConfig", - "edc_list_data.apps.AppConfig", - "edc_protocol.apps.AppConfig", - "edc_metadata.apps.AppConfig", - "edc_device.apps.AppConfig", - "edc_identifier.apps.AppConfig", - "edc_facility.apps.AppConfig", - "edc_label.apps.AppConfig", - "edc_model.apps.AppConfig", - "edc_notification.apps.AppConfig", - "edc_data_manager.apps.AppConfig", - "edc_form_runners.apps.AppConfig", - "edc_registration.apps.AppConfig", - "edc_search.apps.AppConfig", - "edc_sites.apps.AppConfig", - "edc_timepoint.apps.AppConfig", - "edc_visit_schedule.apps.AppConfig", - "edc_visit_tracking.apps.AppConfig", - "edc_offstudy.apps.AppConfig", - "edc_lab.apps.AppConfig", - "lab_app.apps.AppConfig", - "edc_appconfig.apps.AppConfig", - ], - add_dashboard_middleware=True, - use_test_urls=True, -).settings - - -def main(): - func_main(project_settings, f"{app_name}.tests") - +from edc_test_settings.func_main import func_main2 if __name__ == "__main__": - logging.basicConfig() - main() + func_main2("edc_lab.tests.test_settings", "edc_lab.tests") diff --git a/setup.cfg b/setup.cfg index ad91b28..d7f2bcd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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: