Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/template email #84

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/django-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file added experiments/tests/__init__.py
Empty file.
13 changes: 13 additions & 0 deletions experiments/tests/test_email.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion experiments/utils/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) -> \
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = webapp_datastore.settings
2 changes: 2 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pytest
pytest-django
2 changes: 1 addition & 1 deletion requirements.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions webapp_datastore/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'experiments',
'cdh.core',
'cdh.vue',
'cdh.mail',

'impersonate',

Expand Down
Loading