示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
    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(spec=requests.Session, cookies=RequestsCookieJar()), req,
                includes)
示例#5
0
    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
示例#6
0
    def test_session_do_follow_redirects_based_on_global_flag(
            self, req, includes, do_follow):
        """Globally enable following redirects in test"""

        includes["follow_redirects"] = do_follow

        rmock = Mock(spec=requests.Session)
        RestRequest(rmock, req, includes).run()

        assert rmock.request.called
        assert rmock.request.call_args[1]["allow_redirects"] == do_follow