def test_network_400(api, resp_bad): """Should get a NassException without explicit error message""" with pytest.raises(exceptions.NassException): api._handle_response_data({}, resp_bad, '')
def test_generic_error(api, resp_bad): with pytest.raises(exceptions.ApiException) as exc: api._handle_response_data({'error': ['blah']}, resp_bad, '') assert 'Server returned error message ' in str(exc)
def test_exception_list(api, resp_bad): with pytest.raises(exceptions.ExceptionList) as exc: api._handle_response_data({'error': ['a', 'b']}, resp_bad, '') assert 'Server returned error messages ' in str(exc)
def test_bad_response(api, resp_bad): with pytest.raises(exceptions.NassException): api._handle_response_data({}, resp_bad, 'field')
def test_unexpected_response(api, resp_ok): with pytest.raises(exceptions.UnexpectedResponseData): api._handle_response_data({}, resp_ok, 'field')
def test_exceeds_row_limit_weird_format_2(api, resp_bad): with pytest.raises(exceptions.ExceedsRowLimit): api._handle_response_data({'error': ['exceeds limit=a']}, resp_bad, '')
def test_response_not_dict(api, resp_ok): with pytest.raises(exceptions.UnexpectedResponseData): api._handle_response_data(123, resp_ok, 'field')
def test_exception_list(api, resp_bad): with pytest.raises(exceptions.ExceptionList) as exc: api._handle_response_data({"error": ["a", "b"]}, resp_bad, "") assert "Server returned error messages " in str(exc)
def test_network_400(api, resp_bad): """Should get a NassException without explicit error message""" with pytest.raises(exceptions.NassException): api._handle_response_data({}, resp_bad, "")
def test_generic_error(api, resp_bad): with pytest.raises(exceptions.ApiException) as exc: api._handle_response_data({"error": ["blah"]}, resp_bad, "") assert "Server returned error message " in str(exc)
def test_unexpected_response(api, resp_ok): with pytest.raises(exceptions.UnexpectedResponseData): api._handle_response_data({}, resp_ok, "field")
def test_bad_response(api, resp_bad): with pytest.raises(exceptions.NassException): api._handle_response_data({}, resp_bad, "field")
def test_response_not_dict(api, resp_ok): with pytest.raises(exceptions.UnexpectedResponseData): api._handle_response_data(123, resp_ok, "field")
def test_exceeds_row_limit_weird_format_2(api, resp_bad): with pytest.raises(exceptions.ExceedsRowLimit): api._handle_response_data({"error": ["exceeds limit=a"]}, resp_bad, "")