コード例 #1
0
    def test_raise_for_status_429_wrong_headers(self):
        headers = {"Retry-After": "aa"}

        with pytest.raises(exceptions.RateLimited) as exc:
            sansio.raise_for_status(429, headers, {})

        assert exc.type == exceptions.RateLimited
        assert exc.value.retry_after == 1
コード例 #2
0
    def test_raise_for_status_400_httpexception(self):
        with pytest.raises(exceptions.HTTPException) as exc:
            sansio.raise_for_status(400, {"test-header": "hello"},
                                    {"test-data": "world"})

        assert exc.type == exceptions.HTTPException
        assert exc.value.status == 400
        assert exc.value.headers == {"test-header": "hello"}
        assert exc.value.data == {"test-data": "world"}
コード例 #3
0
    def test_raise_for_status_429(self):
        with pytest.raises(exceptions.RateLimited) as exc:
            sansio.raise_for_status(429, {}, {})

        assert exc.type == exceptions.RateLimited
        assert exc.value.retry_after == 1
コード例 #4
0
 def test_raise_for_status_400(self):
     with pytest.raises(exceptions.HTTPException):
         sansio.raise_for_status(400, {}, {})
コード例 #5
0
 def test_raise_for_status_200(self):
     try:
         sansio.raise_for_status(200, {}, {})
     except Exception as exc:
         raise pytest.fail("RAISE {}".format(exc))