Skip to content

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
wants to merge 6 commits into from

Conversation

gaurivn
Copy link
Member

@gaurivn gaurivn commented Apr 9, 2020

Description

Testing whether email is sent for valid mentorship relation requests and whether email is not sent for invalid mentorship relation requests with 2 added unit tests. Changed the version of MarkupSafe (to 1.1.1) in requirements.txt.

Fixes #432

Type of Change:

Delete irrelevant options.

  • Quality Assurance

Code/Quality Assurance Only

  • New feature (non-breaking change which adds functionality pre-approved by mentors)

How Has This Been Tested?

Tests were added to check if email was sent for new mentorship relation requests.

Checklist:

Delete irrelevant options.

  • My PR follows the style guidelines of this project
  • I have performed a self-review of my own code or materials
  • I have commented my code or provided relevant documentation, particularly in hard-to-understand areas
  • Update requirements.txt

Code/Quality Assurance Only

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

@gaurivn I requested some changes, let me know if you have any doubt or disagree with any of the changes :)

@@ -149,3 +149,5 @@ def send_email_new_request(user_sender, user_recipient, notes, sender_role):
)
subject = "Mentorship System - You have got new relation request"
send_email(user_recipient.email, subject, html)

Copy link
Member

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?

Copy link
Member

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

@isabelcosta isabelcosta added the Type: Testing UI Tests, Integration Tests, Travis CI, etc. label Apr 12, 2020
@gaurivn
Copy link
Member Author

gaurivn commented Apr 12, 2020

Sure @isabelcosta thank you, I will make the changes asap.

@gaurivn
Copy link
Member Author

gaurivn commented Apr 12, 2020

@isabelcosta , I made the changes, kindly review them and please tell if I have to make further changes.

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

there is left just some indentation fixes @gaurivn

@@ -45,6 +53,8 @@ def test_fail_send_request_bad_mentor_id(self):
headers=auth_header, content_type='application/json',
data=json.dumps(test_payload))
self.assertEqual(404, actual_response.status_code)
self.assertEqual(1, len(outbox))
Copy link
Member

Choose a reason for hiding this comment

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

is this well indented?

@@ -62,9 +72,45 @@ def test_fail_send_request_bad_user_id(self):
headers=auth_header, content_type='application/json',
data=json.dumps(test_payload))
self.assertEqual(400, actual_response.status_code)
self.assertEqual(1, len(outbox))
Copy link
Member

Choose a reason for hiding this comment

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

is this well indented?

Copy link
Member Author

Choose a reason for hiding this comment

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

@isabelcosta , I have made the required indentation changes after removing unnecessary commits, please review and suggest changes if any.

@@ -149,3 +149,5 @@ def send_email_new_request(user_sender, user_recipient, notes, sender_role):
)
subject = "Mentorship System - You have got new relation request"
send_email(user_recipient.email, subject, html)

Copy link
Member

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

@gaurivn
Copy link
Member Author

gaurivn commented Apr 12, 2020

@isabelcosta , when I checked in gedit editor, it shows proper indentation. I thought it was because of mixing tabs and spaces. I had removed the extra lines under email_utils.py, got a bit confused with the commit conflicts. Can you please check once again and tell if there are any changes I can make.

@gaurivn
Copy link
Member Author

gaurivn commented Apr 13, 2020

@isabelcosta , it is fixed now, I used spaces instead of tab, please review.

Copy link
Member

@isabelcosta isabelcosta left a comment

Choose a reason for hiding this comment

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

Can you please check again code indentation @gaurivn :)

@@ -14,6 +15,12 @@
class TestSendRequestApi(MentorshipRelationBaseTestCase):
def setUp(self):
super(TestSendRequestApi, self).setUp()
self.notes_example = 'description of a good mentorship relation'
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not well indented and that is why TravisCI is failing

Copy link
Member Author

Choose a reason for hiding this comment

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

I indented it properly, replaced tab with proper spaces.

@@ -29,9 +36,10 @@ def test_fail_send_request_bad_mentee_id(self):
headers=auth_header, content_type='application/json',
data=json.dumps(test_payload))
self.assertEqual(404, actual_response.status_code)
self.assertEqual(1, len(outbox))
Copy link
Contributor

Choose a reason for hiding this comment

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

outbox isn't defined here.

Copy link
Member

Choose a reason for hiding this comment

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

@gaurivn can you please define how to get the outbox from the user email

Copy link
Member Author

Choose a reason for hiding this comment

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

@isabelcosta @BadduCoder, can I remove the outbox line

Copy link
Member

Choose a reason for hiding this comment

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

@gaurivn I did a quick search on google to try to figure out how to use the outbox concept, and I found this in the official documentation of Flask-Mail: https://pythonhosted.org/Flask-Mail/#unit-tests-and-suppressing-emails
Can you see if you can fix the outbox usage in this test, before deciding to not use this?

This issue goal is about using something in the code to figure out if the email is being sent, and I think this can be done through this outbox concept

Copy link
Contributor

@sumit-badsara sumit-badsara left a comment

Choose a reason for hiding this comment

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

@gaurivn outbox isn't imported/defined anywhere, which is causing the travis ci failure. Fix that first, and for indentation (maybe use some linter)?

@devkapilbansal
Copy link
Member

@gaurivn can you please make the necessary changes?

@devkapilbansal devkapilbansal added the Status: Changes Requested Changes are required to be done by the PR author. label Feb 20, 2021
@vj-codes
Copy link
Member

@gaurivn closing due to inactivity
Thank you for your contribution :)

@vj-codes vj-codes closed this Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Changes Requested Changes are required to be done by the PR author. Type: Testing UI Tests, Integration Tests, Travis CI, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create tests for checking if email is sent for new mentorship relation requests.
5 participants