Add new utilities for hosting service unit tests.

Review Request #9857 — Created April 4, 2018 and submitted

Christian Hammond
Review Board
release-3.0.x
44cba28...
reviewboard

These new utilities make it easier to test HTTP requests and responses
dealing with multiple paths, and simple responses payloads or errors
with custom headers. It does this through a make_handler_for_paths()
function that takes in a dictionary of information and returns a method
to pass to setup_http_test().

It also adds a dump_json() method that wraps json.dumps() and
returns a bytestring, helping deal with Python 2/3 compatibility.

Used these new methods in upcoming unit tests, which pass.

  • 0
  • 0
  • 2
  • 1
  • 3
Description From Last Updated
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

Christian Hammond
David Trowbridge
  1. 
      
  2. It's probably slightly more correct to say an HTTP handler

  3. 
      
Christian Hammond
David Trowbridge
  1. 
      
  2. This doesn't need the None check: if not isinstance(payload, bytes):

    1. Then it will fail if payload is None. We want to skip the error in this case.

    2. Oh, I got confused with the nots and ands.

  3. 
      
David Trowbridge
  1. Ship It!
  2. 
      
Christian Hammond
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-3.0.x (85d89d5)
Loading...