Skip to content

Commit

Permalink
feat: test specification
Browse files Browse the repository at this point in the history
* To verify that the test is catching the right thing, check the actual log message

FIXES: APER-718
  • Loading branch information
deborahgu committed Aug 31, 2023
1 parent 57732b1 commit b57271d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions credentials/apps/records/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from logging import INFO
import urllib
from logging import INFO

from django.contrib.contenttypes.models import ContentType
from django.core import mail
Expand Down Expand Up @@ -86,8 +86,9 @@ def test_skip_if_user_has_no_program_certificate(self):
# remover the fixture ProgramCertRecord
ProgramCertRecord.objects.get(program=self.program, user=self.user).delete()

with self.assertLogs(level=INFO):
with self.assertLogs(level=INFO) as cm:
send_updated_emails_for_program(self.request, self.USERNAME, self.pc)
self.assertRegex(cm.output[0], r".*ProgramCertRecord for user_uuid .*, program_uuid .* does not exist")

# Check no other email was sent
self.assertEqual(0, len(mail.outbox))
Expand Down
2 changes: 1 addition & 1 deletion credentials/apps/records/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def send_updated_emails_for_program(request, username, program_certificate):
try:
pcr = ProgramCertRecord.objects.get(program=program, user=user)
except ProgramCertRecord.DoesNotExist:
logger.info("Program Cert Record for user_uuid %s, program_uuid %s does not exist", user.id, program.uuid)
logger.info("ProgramCertRecord for user_uuid %s, program_uuid %s does not exist", user.id, program.uuid)
return

# Send emails for those already marked as "SENT"
Expand Down

0 comments on commit b57271d

Please sign in to comment.