def assert_code(response, status_code, msg_prefix=''):
    """Assert the response was returned with the given status code."""
    if msg_prefix:
        msg_prefix = '%s: ' % msg_prefix
    assert response.status_code == status_code, 'Response code was %d (expected %d)' % (
        response.status_code, status_code)
