Skip to content

Commit

Permalink
update format_html, update test settings
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jan 21, 2025
1 parent f21822d commit 0b6d40b
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 104 deletions.
47 changes: 26 additions & 21 deletions edc_he/tests/forms/household_head.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django import forms
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from edc_consent.utils import get_consent_model_cls
from edc_constants.constants import YES
from edc_crf.modelform_mixins import CrfModelFormMixin, CrfSingletonModelFormMixin
Expand Down Expand Up @@ -67,26 +68,30 @@ class Meta:
fields = "__all__"
help_texts = {
"hoh_employment_type": format_html(
'<div class="form-row"><OL><LI><b>Chief executives, managers, senior '
"officials and legislators</b> </li>"
"<LI><b>Professionals, technicians and associate professionals</b> (e.g. "
"science/engineering professionals, architects, nurses, doctors, teachers, "
"technicians, construction/mining supervisors, etc.)</li>"
"<LI><b>Clerks</b> (e.g. clerical support workers, receptionist, secretary, "
"postman/woman etc.) </li>"
"<LI><b>Service workers and shop sale workers</b> (e.g. shop sales, cooks, "
"waiter/bartenders, hairdressers, caretakers, street food/stall salespersons, "
"childcare workers, teachers aides, healthcare/personal care "
"assistants etc.) </li>"
"<LI><b>Large-scale agricultural, forestry and fishery workers</b> </li>"
"<LI><b>Subsistence farmers, fishers, etc.</b></li>"
"<LI><b>Craft and related workers</b> (e.g. builders, plumbers, painters, "
"mechanics, craftsmen, potters, welders, etc.) </li>"
"<LI><b>Plant and machine operators and assemblers, drivers</b> (e.g. "
"factory/plant operators, miners, truck/bus drivers, taxi drivers, "
"train drivers, etc.) </li>"
"<LI><b>Elementary occupations</b> (e.g. cleaners, farm pickers/labourers, "
"rickshaw drivers, builder assistants, hawkers, shoe shiners, street car "
"cleaners, garbage collectors, street sweepers, etc.) </li></ol></div>"
"{}",
mark_safe(
'<div class="form-row"><OL><LI><b>Chief executives, managers, senior '
"officials and legislators</b> </li>"
"<LI><b>Professionals, technicians and associate professionals</b> (e.g. "
"science/engineering professionals, architects, nurses, doctors, "
"teachers, technicians, construction/mining supervisors, etc.)</li>"
"<LI><b>Clerks</b> (e.g. clerical support workers, receptionist, "
"secretary, postman/woman etc.) </li>"
"<LI><b>Service workers and shop sale workers</b> (e.g. shop sales, "
"cooks, waiter/bartenders, hairdressers, caretakers, street food/stall "
"salespersons, childcare workers, teachers aides, healthcare/personal "
"care assistants etc.) </li>"
"<LI><b>Large-scale agricultural, forestry and fishery workers</b> </li>"
"<LI><b>Subsistence farmers, fishers, etc.</b></li>"
"<LI><b>Craft and related workers</b> (e.g. builders, plumbers, painters, "
"mechanics, craftsmen, potters, welders, etc.) </li>"
"<LI><b>Plant and machine operators and assemblers, drivers</b> (e.g. "
"factory/plant operators, miners, truck/bus drivers, taxi drivers, "
"train drivers, etc.) </li>"
"<LI><b>Elementary occupations</b> (e.g. cleaners, farm pickers/"
"labourers, rickshaw drivers, builder assistants, hawkers, shoe shiners, "
"street car cleaners, garbage collectors, street sweepers, etc.) "
"</li></ol></div>"
), # nosec B703, B308
)
}
71 changes: 71 additions & 0 deletions edc_he/tests/test_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/env python
import sys
from pathlib import Path

from edc_test_settings.default_test_settings import DefaultTestSettings

app_name = "edc_he"

base_dir = Path(__file__).absolute().parent.parent.parent

project_settings = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=base_dir / app_name / "tests" / "etc",
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
EDC_SITES_REGISTER_DEFAULT=True,
SUBJECT_SCREENING_MODEL="edc_metadata.subjectscreening",
SUBJECT_CONSENT_MODEL="edc_metadata.subjectconsent",
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="edc_metadata.subjectvisitmissed",
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"multisite",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_adverse_event.apps.AppConfig",
"adverse_event_app.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_listboard.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_navbar.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_he.apps.AppConfig",
"visit_schedule_app.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
RANDOMIZATION_LIST_PATH=base_dir / app_name / "tests" / "test_randomization_list.csv",
add_dashboard_middleware=True,
).settings

for k, v in project_settings.items():
setattr(sys.modules[__name__], k, v)
85 changes: 2 additions & 83 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,5 @@
#!/usr/bin/env python
import logging
import sys
from os.path import abspath, dirname, join

import django
from django.conf import settings
from django.test.runner import DiscoverRunner
from edc_test_utils import DefaultTestSettings

base_dir = dirname(abspath(__file__))
app_name = "edc_he"


DEFAULT_SETTINGS = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=join(base_dir, app_name, "tests", "etc"),
SILENCED_SYSTEM_CHECKS=[
"sites.E101",
"edc_navbar.E002",
"edc_navbar.E003",
"edc_consent.E001",
"edc_sites.E001",
"edc_sites.E002",
],
EDC_SITES_REGISTER_DEFAULT=True,
SUBJECT_SCREENING_MODEL="edc_metadata.subjectscreening",
SUBJECT_CONSENT_MODEL="edc_metadata.subjectconsent",
SUBJECT_VISIT_MODEL="edc_visit_tracking.subjectvisit",
SUBJECT_VISIT_MISSED_MODEL="edc_metadata.subjectvisitmissed",
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.sites",
"multisite",
"django_crypto_fields.apps.AppConfig",
"django_revision.apps.AppConfig",
"edc_action_item.apps.AppConfig",
"edc_adverse_event.apps.AppConfig",
"adverse_event_app.apps.AppConfig",
"edc_appointment.apps.AppConfig",
"edc_auth.apps.AppConfig",
"edc_dashboard.apps.AppConfig",
"edc_data_manager.apps.AppConfig",
"edc_facility.apps.AppConfig",
"edc_form_runners.apps.AppConfig",
"edc_lab.apps.AppConfig",
"edc_list_data.apps.AppConfig",
"edc_listboard.apps.AppConfig",
"edc_metadata.apps.AppConfig",
"edc_navbar.apps.AppConfig",
"edc_notification.apps.AppConfig",
"edc_registration.apps.AppConfig",
"edc_review_dashboard.apps.AppConfig",
"edc_sites.apps.AppConfig",
"edc_subject_dashboard.apps.AppConfig",
"edc_visit_schedule.apps.AppConfig",
"edc_visit_tracking.apps.AppConfig",
"edc_timepoint.apps.AppConfig",
"edc_he.apps.AppConfig",
"visit_schedule_app.apps.AppConfig",
"edc_appconfig.apps.AppConfig",
],
RANDOMIZATION_LIST_PATH=join(base_dir, app_name, "tests", "test_randomization_list.csv"),
add_dashboard_middleware=True,
).settings


def main():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
tags = [t.split("=")[1] for t in sys.argv if t.startswith("--tag")]
failures = DiscoverRunner(failfast=False, tags=tags).run_tests([f"{app_name}.tests"])
sys.exit(failures)

from edc_test_settings.func_main import func_main2

if __name__ == "__main__":
logging.basicConfig()
main()
func_main2("edc_he.tests.test_settings", "edc_he.tests")

0 comments on commit 0b6d40b

Please sign in to comment.