-
Notifications
You must be signed in to change notification settings - Fork 447
test: Check if email is sent for new mentorship relation requests #536
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
87d0bc6
test: Check if email is sent for new mentorship relation requests
gaurivn f3f3c64
Made changes
gaurivn 55f4f17
to be force pushed
gaurivn 3e63f1e
removed space in app/api/email_utils.py
gaurivn 1cbae6d
Merge branch 'develop' of https://github.com/systers/mentorship-backe…
gaurivn f39e011
Fixed indentation
gaurivn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
isabelcosta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from datetime import datetime, timedelta | ||
from app.api.mail_extension import mail | ||
from tests.mentorship_relation.relation_base_setup import MentorshipRelationBaseTestCase | ||
from tests.test_utils import get_test_request_header | ||
|
||
class TestCreateMentorshipRequestApi(MentorshipRelationBaseTestCase): | ||
|
||
# Setup consists of adding 2 users into the database | ||
# User 1 is the mentorship relation requester = action user | ||
# User 2 is the receiver | ||
def setUp(self): | ||
super(TestCreateMentorshipRequestApi, self).setUp() | ||
|
||
self.notes_example = 'description of a good mentorship relation' | ||
self.now_datetime = datetime.now() | ||
self.end_date_example = self.now_datetime + timedelta(weeks=5) | ||
|
||
mail.init_app(self.app) | ||
|
||
def test_create_mentorship_request(self): | ||
with mail.record_messages() as outbox: | ||
with self.client: | ||
response = self.client.post('/mentorship_relation/send_request', | ||
headers=get_test_request_header(self.first_user.id), | ||
json={ | ||
"mentor_id": self.first_user.id, | ||
"mentee_id": self.second_user.id, | ||
"end_date": self.end_date_example.timestamp(), | ||
"notes": self.notes_example | ||
}) | ||
|
||
self.assertEqual(200, response.status_code) | ||
self.assertEqual(1, len(outbox)) | ||
isabelcosta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual([self.second_user.email], outbox[0].recipients) | ||
|
||
def test_create_invalid_mentorship_request(self): | ||
with mail.record_messages() as outbox: | ||
with self.client: | ||
# receiver's id and action user's id are equal | ||
response = self.client.post('/mentorship_relation/send_request', | ||
headers=get_test_request_header(self.first_user.id), | ||
json={ | ||
"mentor_id": self.first_user.id, | ||
"mentee_id": self.first_user.id, | ||
"end_date": self.end_date_example.timestamp(), | ||
"notes": self.notes_example | ||
}) | ||
self.assertNotEqual(200, response.status_code) | ||
self.assertEqual(0, len(outbox)) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you undo these changes? just to keep the changes to test module?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove these changes? I can merge them but if you could take these off as well. This seems like style format changes, that can be done in another PR