Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add more unit tests #164

Closed
wants to merge 1 commit into from
Closed

Conversation

cfreksen
Copy link

This adds more unit tests (and fixes a broken one) so that almost all code is covered.

Signed-off-by: cfreksen <casper@freksen.dk>
@joshcanhelp
Copy link
Contributor

Thank you for this @cfreksen! We'll get this reviewed as soon as we can.

mock_get.assert_called_with(url='the-url', params={'a': 'b'},
headers={'c': 'd'})

self.assertEqual(result, '{"x": "y"}')
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also assert the status code?


for error_status in [400, 500, None]:
mock_post.return_value.status_code = error_status
mock_post.return_value.text = '{"error": "SomeError"}'
Copy link
Contributor

Choose a reason for hiding this comment

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

Our errors typically come back with both an error property and an error_description one. I don't know OTOH but I'm guessing the exception that's returned will include the description as an error message. Might be good to check for that as well.

@@ -17,11 +17,11 @@ def test_get(self, mock_rc):
)

@mock.patch('auth0.v3.management.jobs.RestClient')
def get_failed_job(self, mock_rc):
def test_get_failed_job(self, mock_rc):
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

self.assertEqual(context.exception.error_code, 'SomeError')

@mock.patch('requests.post')
def test_file_post(self, mock_post):
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing this anywhere in the SDK?

self.assertEqual(response, {'a': 'b'})

@mock.patch('requests.post')
def test_file_post_errors(self, mock_post):
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we doing this anywhere in the SDK?

@lbalmaceda
Copy link
Contributor

@cfreksen any extra guidance you need to complete this PR? Don't hesitate to ask any questions.

@joshcanhelp
Copy link
Contributor

@cfreksen - We'd like to merge this but need a few changes. We'll leave this open for a bit longer and then we'll have to close it. Thank you!

@lbalmaceda lbalmaceda closed this Jun 7, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants