Skip to content

Commit

Permalink
Merge branch 'release/0.3.10' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Sep 10, 2024
2 parents 63efd39 + ad9f5fa commit c8efd90
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 106 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
21 changes: 11 additions & 10 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,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:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.1 on 2024-09-09 14:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("edc_action_item", "0037_remove_actionitem_reference_model_and_more"),
("edc_pharmacy", "0022_alter_historicalproduct_site_alter_historicalrx_site_and_more"),
("sites", "0002_alter_domain_unique"),
]

operations = [
migrations.RemoveIndex(
model_name="rx",
name="edc_pharmac_modifie_986021_idx",
),
migrations.RemoveIndex(
model_name="rx",
name="edc_pharmac_user_mo_b9ac53_idx",
),
migrations.AddIndex(
model_name="rx",
index=models.Index(fields=["rando_sid"], name="edc_pharmac_rando_s_0bcc84_idx"),
),
]
3 changes: 2 additions & 1 deletion edc_pharmacy/models/rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.db.models import PROTECT
from django.db.models import PROTECT, Index
from edc_action_item.models import ActionModelMixin
from edc_constants.constants import NEW
from edc_identifier.model_mixins import NonUniqueSubjectIdentifierFieldMixin
Expand Down Expand Up @@ -133,3 +133,4 @@ def description(self):
class Meta(BaseUuidModel.Meta):
verbose_name = "Prescription"
verbose_name_plural = "Prescriptions"
indexes = [Index(fields=["rando_sid"])]
1 change: 0 additions & 1 deletion edc_pharmacy/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .models import OffSchedule, OnSchedule, StudyMedication
2 changes: 0 additions & 2 deletions edc_pharmacy/tests/consents.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from edc_consent.consent_definition import ConsentDefinition
from edc_consent.site_consents import site_consents
from edc_constants.constants import FEMALE, MALE
from edc_protocol.research_protocol_config import ResearchProtocolConfig

Expand All @@ -13,4 +12,3 @@
age_max=64,
gender=[MALE, FEMALE],
)
site_consents.register(consent_v1)
67 changes: 67 additions & 0 deletions edc_pharmacy/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python
import sys
from pathlib import Path

from dateutil.relativedelta import relativedelta
from edc_test_settings.default_test_settings import DefaultTestSettings
from edc_utils import get_utcnow

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

project_settings = DefaultTestSettings(
calling_file=__file__,
SILENCED_SYSTEM_CHECKS=["sites.E101", "edc_navbar.E002", "edc_navbar.E003"],
EDC_AUTH_CODENAMES_WARN_ONLY=True,
EDC_AUTH_SKIP_SITE_AUTHS=True,
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)
),
EDC_PROTOCOL_STUDY_CLOSE_DATETIME=(
get_utcnow().replace(microsecond=999999, second=59, minute=59, hour=11)
+ relativedelta(years=6)
),
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",
"multisite",
"edc_action_item.apps.AppConfig",
"edc_adverse_event.apps.AppConfig",
"adverse_event_app.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_device.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_identifier.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_offstudy.apps.AppConfig",
"edc_randomization.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_pharmacy.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
add_dashboard_middleware=True,
).settings


for k, v in project_settings.items():
setattr(sys.modules[__name__], k, v)
6 changes: 6 additions & 0 deletions edc_pharmacy/tests/tests/test_stock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from dateutil.relativedelta import relativedelta
from django.test import TestCase
from edc_consent import site_consents
from edc_list_data import site_list_data
from edc_utils import get_utcnow

Expand All @@ -22,11 +23,16 @@
get_shelf,
)

from ..consents import consent_v1


class TestPrescription(TestCase):
def setUp(self):
site_list_data.initialize()
site_list_data.autodiscover()
site_consents.registry = {}
site_consents.loaded = False
site_consents.register(consent_v1)

self.medication = Medication.objects.create(
name="METFORMIN",
Expand Down
6 changes: 6 additions & 0 deletions edc_pharmacy/tests/tests/test_study_medication_crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from edc_appointment.models import Appointment
from edc_appointment.tests.helper import Helper
from edc_appointment.utils import get_next_appointment
from edc_consent import site_consents
from edc_constants.constants import YES
from edc_facility import import_holidays
from edc_protocol.research_protocol_config import ResearchProtocolConfig
Expand All @@ -32,6 +33,7 @@
Units,
)

from ..consents import consent_v1
from ..forms import StudyMedicationForm
from ..models import StudyMedication, SubjectVisit
from ..visit_schedule import visit_schedule
Expand All @@ -47,6 +49,10 @@ def setUpTestData(cls):
pre_save.disconnect(dispatch_uid="requires_consent_on_pre_save")

def setUp(self) -> None:
site_consents.registry = {}
site_consents.loaded = False
site_consents.register(consent_v1)

site_visit_schedules._registry = {}
site_visit_schedules.loaded = False
site_visit_schedules.register(visit_schedule)
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
Loading

0 comments on commit c8efd90

Please sign in to comment.