Skip to content

Commit

Permalink
Correct failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-li committed Jan 20, 2022
1 parent c7caa42 commit 9887160
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9887160

Please sign in to comment.