Merge lp:~tartley/canonical-identity-provider/status-code-diagnostics into lp:canonical-identity-provider/release

Proposed by Jonathan Hartley
Status: Merged
Approved by: Jonathan Hartley
Approved revision: no longer in the source branch.
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: lp:~tartley/canonical-identity-provider/status-code-diagnostics
Merge into: lp:canonical-identity-provider/release
Prerequisite: lp:~tartley/canonical-identity-provider/allow-new-emails
Diff against target: 15 lines (+4/-1)
1 file modified
src/api/v20/tests/test_handlers.py (+4/-1)
To merge this branch: bzr merge lp:~tartley/canonical-identity-provider/status-code-diagnostics
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Review via email: mp+377377@code.launchpad.net

Commit message

Test fail diagnostics for bad response status code.

If a response has an unexpected status code,
display the response content
and the expected/actual status codes.

Description of the change

This is an annoyingly tiny MP, but I wanted to make sure this change gets in regardless what happens to my other MPs, which are all potentially more controversial.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

LGTM with two caveats/comments.

1- Would .format() syntax be clearer/nicer? (I prefer .format but don't mind old % syntax)
2- If response is big, this will cause horrid test output spew. It might be desirable, or may not. Not sure there's a good alternative :/ truncating it might risk losing the actual part in conflict.

review: Approve
Revision history for this message
Jonathan Hartley (tartley) wrote :

> LGTM with two caveats/comments.
>
> 1- Would .format() syntax be clearer/nicer? (I prefer .format but don't mind
> old % syntax)
> 2- If response is big, this will cause horrid test output spew. It might be
> desirable, or may not. Not sure there's a good alternative :/ truncating it
> might risk losing the actual part in conflict.

FWIW, the original code already output the response content, with potential spew. This change just adds the actual/expected response code too.

Having said that, truncating seems harmless. Worse case, for massive responses, the dev will need to do some more investigation.

Revision history for this message
Jonathan Hartley (tartley) wrote :

From IRC

<roadmr>: for status-code-diagnostics, I think it can land as-is, no need to truncate the spew

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/api/v20/tests/test_handlers.py'
2--- src/api/v20/tests/test_handlers.py 2020-01-09 16:04:03 +0000
3+++ src/api/v20/tests/test_handlers.py 2020-01-09 16:04:03 +0000
4@@ -95,7 +95,10 @@
5 response = getattr(self.client, method.lower())(url, **kwargs)
6 if status_code is not None:
7 self.assertEqual(
8- response.status_code, status_code, response.content)
9+ response.status_code, status_code, "%s != %s\n%s" % (
10+ response.status_code, status_code, response.content
11+ )
12+ )
13 return response
14
15 def do_request(self, method, data=None, raw_data=None, url=None,