From 9887160c36bcd643f9215f874066eec7ebbc6636 Mon Sep 17 00:00:00 2001 From: Matthew Li Date: Thu, 20 Jan 2022 13:24:27 -0800 Subject: [PATCH] Correct failing test --- .../test_views/test_auto_approval_removal.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/coldfront/core/project/tests/test_views/test_auto_approval_removal.py b/coldfront/core/project/tests/test_views/test_auto_approval_removal.py index 53d4c715c..458542952 100644 --- a/coldfront/core/project/tests/test_views/test_auto_approval_removal.py +++ b/coldfront/core/project/tests/test_views/test_auto_approval_removal.py @@ -3,17 +3,18 @@ from django.contrib.messages import get_messages from django.urls import reverse -from coldfront.core.project.forms import ProjectReviewUserJoinForm from coldfront.core.project.models import * from coldfront.core.user.models import UserProfile from django.test import TestCase from django.contrib.auth.models import User from django.core import mail from django.core.management import call_command +from coldfront.core.utils.common import import_from_settings from coldfront.core.utils.common import utc_now_offset_aware from django.conf import settings from io import StringIO +from urllib.parse import urljoin import os import sys @@ -155,13 +156,21 @@ def test_project_join_request_email(self): role__name__in=['Manager', 'Principal Investigator'], status__name='Active')] - email_body = f'User {self.user1.first_name} {self.user1.last_name} ' \ - f'({self.user1.email}) has requested to join your ' \ - f'project, {self.project1.name} via MyBRC user portal. ' \ - f'Please approve/deny this request.' + domain = import_from_settings('CENTER_BASE_URL') + view = reverse( + 'project-review-join-requests', kwargs={'pk': self.project1.pk}) + review_url = urljoin(domain, view) + + body_components = [ + (f'User {self.user1.first_name} {self.user1.last_name} ' + f'({self.user1.email}) has requested to join your project, ' + f'{self.project1.name} via the MyBRC User Portal.'), + f'Please approve/deny this request here: {review_url}.', + ] for email in mail.outbox: - self.assertIn(email_body, email.body) + for component in body_components: + self.assertIn(component, email.body) for recipient in email.to: self.assertIn(recipient, email_to_list) self.assertEqual(settings.EMAIL_SENDER, email.from_email)