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

Add unit tests for notify.py #1409

Merged
merged 2 commits into from
Jan 11, 2024
Merged

Add unit tests for notify.py #1409

merged 2 commits into from
Jan 11, 2024

Conversation

hacktobeer
Copy link
Collaborator

Description of the change

Adds unit tests for notify.py as it lacks any unit tests.

Applicable issues

None

Checklist

  • All tests were successful.
  • Unit tests added.

@aarontp
Copy link
Member

aarontp commented Jan 9, 2024

Nice, always glad to see more tests :). Is this ready for review?

@hacktobeer
Copy link
Collaborator Author

Nice, always glad to see more tests :). Is this ready for review?

I forgot about this PR, yes, let's review. I'll assign.

@hacktobeer hacktobeer requested a review from aarontp January 9, 2024 15:44
# Test that email is not sent when EMAIL_PASSWORD is not defined
mock_smtp.reset_mock()
self.config.EMAIL_PASSWORD = ''
with self.assertLogs('turbinia', level='INFO') as turbinia_info_log:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah, cool, I didn't know assertLogs was a thing, nice.

pass
self.assertEqual(
turbinia_error_log.output[1],
'ERROR:turbinia:Email failed to send, SMTP has raised an error, '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I might say this is a little brittle since it will fail if the logging message or formatting changes, but this notify module hasn't changed in quite a while so I think it's probably just fine to leave it for now, and if things change we can update as needed (e.g. have a different check, or maybe just check a substring).

@aarontp aarontp merged commit 2174e9a into google:master Jan 11, 2024
5 checks passed
jleaniz pushed a commit to jleaniz/turbinia that referenced this pull request Feb 28, 2024
* Write missing notify.py test. 100% coverage reported.

* yapf
jleaniz pushed a commit to jleaniz/turbinia that referenced this pull request Mar 18, 2024
* Write missing notify.py test. 100% coverage reported.

* yapf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants