diff --git a/config-example.json b/config-example.json index a04ee059f8b528a5821205dc507765c0e6751aa8..f712e8b4cb8f8c88cbf809350526a41a330afdec 100644 --- a/config-example.json +++ b/config-example.json @@ -6,5 +6,13 @@ "client_secret": "<secret>", "server_metadata_url": "https://accounts.google.com/.well-known/openid-configuration" }, - "SECRET_KEY": "changeme" + "SECRET_KEY": "changeme", + "mail": { + "MAIL_SERVER": "mail.geant.net", + "MAIL_PORT": 25, + "MAIL_SENDER_EMAIL": "compendium@geant.org", + "MAIL_EXCLUDED_ADMINS": [ + "bjarke@nordu.net" + ] + } } diff --git a/test/conftest.py b/test/conftest.py index 001aee506856395d69d023cb33d57a2aef8bb204..154265bc3a3fedbd494443132232e80868177957 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -26,7 +26,7 @@ def dummy_config(): @pytest.fixture -def mocked_admin_user(app, mocker): +def mocked_admin_user(app, test_survey_data, mocker): with app.app_context(): user = User(email='testemail123@email.local', fullname='testfullname', oidc_sub='fakesub', roles=ROLES.admin) @@ -42,7 +42,7 @@ def mocked_admin_user(app, mocker): @pytest.fixture -def mocked_user(app, mocker): +def mocked_user(app, test_survey_data, mocker): with app.app_context(): user = User(email='testemail123@email.local', fullname='testfullname', oidc_sub='fakesub') diff --git a/test/test_send_mail.py b/test/test_send_mail.py new file mode 100644 index 0000000000000000000000000000000000000000..a1725367f4f4230b769f6338760c10c5d48c8d1f --- /dev/null +++ b/test/test_send_mail.py @@ -0,0 +1,16 @@ +from compendium_v2.email import send_mail + + +def test_email(app, mocked_admin_user, mocker): + + def _send_mail(*args, **kwargs): + pass + + mocker.patch('compendium_v2.email._send_mail', _send_mail) + with app.app_context(): + app.config['MAIL_ENABLE'] = True + app.config['MAIL_SERVER'] = 'localhost' + app.config['MAIL_PORT'] = 54655 + app.config['MAIL_SENDER_EMAIL'] = 'fakesender123@test.local' + app.config['MAIL_EXCLUDED_ADMINS'] = [] + send_mail('testmail321')