From eec44e7277277f66da64cca6cbeda6c743071897 Mon Sep 17 00:00:00 2001 From: erikvw Date: Wed, 13 Dec 2023 01:03:04 -0600 Subject: [PATCH 1/2] register default site for tests --- edc_pharmacy/migrations/0018_alter_rxrefill_managers.py | 5 +++-- ..._alter_box_options_alter_container_options_and_more.py | 8 +++++--- edc_pharmacy/tests/tests/test_packaging.py | 5 ++--- edc_pharmacy/tests/tests/test_study_medication_crf.py | 2 +- runtests.py | 5 +++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/edc_pharmacy/migrations/0018_alter_rxrefill_managers.py b/edc_pharmacy/migrations/0018_alter_rxrefill_managers.py index 695f01f..1aa9b77 100644 --- a/edc_pharmacy/migrations/0018_alter_rxrefill_managers.py +++ b/edc_pharmacy/migrations/0018_alter_rxrefill_managers.py @@ -1,8 +1,9 @@ # Generated by Django 4.2.1 on 2023-07-07 19:32 +import edc_sites.models from django.db import migrations + import edc_pharmacy.models.rx_refill -import edc_sites.model_mixins class Migration(migrations.Migration): @@ -18,7 +19,7 @@ class Migration(migrations.Migration): name="rxrefill", managers=[ ("objects", edc_pharmacy.models.rx_refill.Manager()), - ("on_site", edc_sites.model_mixins.CurrentSiteManager()), + ("on_site", edc_sites.models.CurrentSiteManager()), ], ), ] diff --git a/edc_pharmacy/migrations/0021_alter_box_options_alter_container_options_and_more.py b/edc_pharmacy/migrations/0021_alter_box_options_alter_container_options_and_more.py index 8c78270..e25fa6c 100644 --- a/edc_pharmacy/migrations/0021_alter_box_options_alter_container_options_and_more.py +++ b/edc_pharmacy/migrations/0021_alter_box_options_alter_container_options_and_more.py @@ -1,9 +1,11 @@ # Generated by Django 4.2.7 on 2023-12-04 22:19 +import uuid + +import edc_sites.models from django.db import migrations, models + import edc_pharmacy.models.rx -import edc_sites.model_mixins -import uuid class Migration(migrations.Migration): @@ -456,7 +458,7 @@ class Migration(migrations.Migration): name="rx", managers=[ ("objects", edc_pharmacy.models.rx.Manager()), - ("on_site", edc_sites.model_mixins.CurrentSiteManager()), + ("on_site", edc_sites.models.CurrentSiteManager()), ], ), migrations.RemoveIndex( diff --git a/edc_pharmacy/tests/tests/test_packaging.py b/edc_pharmacy/tests/tests/test_packaging.py index ba2b4aa..d6a7f96 100644 --- a/edc_pharmacy/tests/tests/test_packaging.py +++ b/edc_pharmacy/tests/tests/test_packaging.py @@ -1,11 +1,10 @@ from dateutil.relativedelta import relativedelta -from django.test import TestCase +from django.test import TestCase, override_settings from edc_facility import import_holidays from edc_list_data import site_list_data from edc_randomization.constants import ACTIVE, PLACEBO from edc_randomization.site_randomizers import site_randomizers from edc_randomization.tests.testcase_mixin import TestCaseMixin, all_sites -from edc_sites import add_or_update_django_sites from edc_utils import get_utcnow from edc_pharmacy.exceptions import InsufficientQuantityError @@ -28,6 +27,7 @@ ) +@override_settings(SITE_ID=1) class TestPackaging(TestCaseMixin, TestCase): import_randomization_list = True site_names = [x.name for x in all_sites] @@ -36,7 +36,6 @@ class TestPackaging(TestCaseMixin, TestCase): @classmethod def setUpTestData(cls): import_holidays(test=True) - add_or_update_django_sites(sites=all_sites) if cls.import_randomization_list: randomizer_cls = site_randomizers.get("default") randomizer_cls.import_list( diff --git a/edc_pharmacy/tests/tests/test_study_medication_crf.py b/edc_pharmacy/tests/tests/test_study_medication_crf.py index d622f9c..d587f8a 100644 --- a/edc_pharmacy/tests/tests/test_study_medication_crf.py +++ b/edc_pharmacy/tests/tests/test_study_medication_crf.py @@ -36,7 +36,7 @@ from ..visit_schedule import visit_schedule -@override_settings(SUBJECT_CONSENT_MODEL="edc_pharmacy.subjectconsent") +@override_settings(SUBJECT_CONSENT_MODEL="edc_pharmacy.subjectconsent", SITE_ID=1) class TestMedicationCrf(TestCase): helper_cls = Helper diff --git a/runtests.py b/runtests.py index b071adf..fb6369d 100644 --- a/runtests.py +++ b/runtests.py @@ -1,6 +1,6 @@ #!/usr/bin/env python import logging -from os.path import abspath, dirname +from pathlib import Path from dateutil.relativedelta import relativedelta from edc_constants.constants import IGNORE @@ -8,7 +8,7 @@ from edc_utils import get_utcnow app_name = "edc_pharmacy" -base_dir = dirname(abspath(__file__)) +base_dir = Path(__file__).absolute().parent project_settings = DefaultTestSettings( calling_file=__file__, @@ -18,6 +18,7 @@ EDC_AUTH_SKIP_AUTH_UPDATER=True, BASE_DIR=base_dir, APP_NAME=app_name, + EDC_SITES_REGISTER_DEFAULT=True, EDC_PROTOCOL_STUDY_OPEN_DATETIME=( get_utcnow().replace(microsecond=0, second=0, minute=0, hour=0) - relativedelta(years=6) From 3a8570b13af7891abcbdec9f87566ed7eb107a6d Mon Sep 17 00:00:00 2001 From: erikvw Date: Wed, 13 Dec 2023 09:48:17 -0600 Subject: [PATCH 2/2] test setup --- .github/workflows/build.yml | 10 ++++++++-- pyproject.toml | 14 ++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39f9299..4ec2681 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,8 +11,14 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.11'] - django-version: ['4.2', 'dev'] + python-version: ['3.11', '3.12'] + django-version: ['4.2', '5.0', 'dev'] + + exclude: + - python-version: '3.12' + django-version: '4.2' + - python-version: '3.11' + django-version: 'dev' services: mysql: image: mysql:latest diff --git a/pyproject.toml b/pyproject.toml index 5ffc4e4..d28ad31 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,20 +35,22 @@ exclude_lines = [ legacy_tox_ini = """ [tox] envlist = - py{311}-dj{41,42,dev}, + py{311}-dj{42,50}, + py{312}-dj{50,dev}, lint isolated_build = true [gh-actions] python = - 3.11: py311, lint + 3.11: py311 + 3.12: py312, lint [gh-actions:env] DJANGO = - 4.1: dj41 - 4.2: dj42, lint - dev: djdev + 4.2: dj42 + 5.0: dj50 + dev: djdev, lint [testenv] deps = @@ -56,8 +58,8 @@ deps = -r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/test_utils.txt -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 - dj41: Django>=4.1,<4.2 dj42: Django>=4.2,<5.0 + dj50: Django>=5.0 djdev: https://github.com/django/django/tarball/main commands =