def test_missing_format(self, req, includes): """All format variables should be present """ del includes["variables"]["code"] with pytest.raises(exceptions.MissingFormatError): RestRequest(Mock(), req, includes)
def test_bad_get_body(self, req, includes): """Can't add a body with a GET request """ req["method"] = "GET" with pytest.warns(RuntimeWarning): RestRequest(Mock(), req, includes)
def test_unknown_fields(self, req, includes): """Unkown args should raise an error """ req["fodokfowe"] = "Hello" with pytest.raises(exceptions.UnexpectedKeysError): RestRequest(Mock(), req, includes)
def test_session_called_no_redirects(self, req, includes): """Always disable redirects """ rmock = Mock(spec=requests.Session) RestRequest(rmock, req, includes).run() assert rmock.request.called assert rmock.request.call_args[1]["allow_redirects"] == False