diff --git a/.github/workflows/django-tests.yml b/.github/workflows/django-tests.yml index 7053d94..3bc213a 100644 --- a/.github/workflows/django-tests.yml +++ b/.github/workflows/django-tests.yml @@ -30,9 +30,10 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install -r requirements.dev.txt - name: Compile messages run: | python manage.py compilemessages - name: Run Tests run: | - python manage.py test + pytest diff --git a/experiments/tests/__init__.py b/experiments/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/experiments/tests/test_email.py b/experiments/tests/test_email.py new file mode 100644 index 0000000..63e1059 --- /dev/null +++ b/experiments/tests/test_email.py @@ -0,0 +1,13 @@ +from main.models import User +from ..models import Experiment +from ..utils import send_new_experiment_mail + + +def test_new_experiment_mail(db, rf, mailoutbox): + experiment = Experiment.objects.create(title='CoolExp') + user = User.objects.create(first_name='John', last_name='Doe') + request = rf.get('/') + send_new_experiment_mail(experiment, user, request) + assert len(mailoutbox) == 1 + assert 'CoolExp' in mailoutbox[0].body + assert 'John Doe' in mailoutbox[0].body diff --git a/experiments/tests.py b/experiments/tests/test_experiments.py similarity index 98% rename from experiments/tests.py rename to experiments/tests/test_experiments.py index 13b5a71..c254473 100644 --- a/experiments/tests.py +++ b/experiments/tests/test_experiments.py @@ -9,7 +9,7 @@ import uuid # Create your tests here. -from .models import Experiment, ParticipantSession, TargetGroup, DataPoint +from ..models import Experiment, ParticipantSession, TargetGroup, DataPoint class ParticipantSessionSubjectIdTests(TestCase): diff --git a/experiments/utils/mails.py b/experiments/utils/mails.py index f1607b5..d953362 100644 --- a/experiments/utils/mails.py +++ b/experiments/utils/mails.py @@ -3,7 +3,7 @@ from experiments.models import Experiment from main.models import User -from cdh.core.mail import send_template_email +from cdh.mail.utils import send_template_email def send_new_experiment_mail(experiment: Experiment, user: User, request) -> \ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..e5e5e57 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +DJANGO_SETTINGS_MODULE = webapp_datastore.settings diff --git a/requirements.dev.txt b/requirements.dev.txt new file mode 100644 index 0000000..125b460 --- /dev/null +++ b/requirements.dev.txt @@ -0,0 +1,2 @@ +pytest +pytest-django diff --git a/requirements.in b/requirements.in index 8e67707..a43c9f0 100644 --- a/requirements.in +++ b/requirements.in @@ -1,5 +1,5 @@ Django>=4.2,<5 -cdh-django-core[all] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@v3.1.0 +cdh-django-core[all] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@v3.2.0 django-axes django-auth-ldap django-cors-headers diff --git a/requirements.txt b/requirements.txt index 60c4d4b..eb3be0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,7 +19,7 @@ bpython==0.24 # via cdh-django-core build==1.2.1 # via pip-tools -cdh-django-core[all,core,federated-auth,files,recommended,rest,vue] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@v3.1.0 +cdh-django-core[all,core,federated-auth,files,mail,recommended,rest,vue] @ git+https://github.com/CentreForDigitalHumanities/django-shared-core.git@v3.2.0 # via -r requirements.in certifi==2024.7.4 # via requests @@ -79,7 +79,9 @@ django-debug-toolbar==4.4.6 django-extensions==3.2.3 # via cdh-django-core django-filter==24.2 - # via -r requirements.in + # via + # -r requirements.in + # cdh-django-core django-impersonate==1.9.4 # via # -r requirements.in diff --git a/webapp_datastore/settings.py b/webapp_datastore/settings.py index 9815d8f..651b395 100644 --- a/webapp_datastore/settings.py +++ b/webapp_datastore/settings.py @@ -74,6 +74,7 @@ 'experiments', 'cdh.core', 'cdh.vue', + 'cdh.mail', 'impersonate',