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
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"}
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
def test_raise_for_status_400(self): with pytest.raises(exceptions.HTTPException): sansio.raise_for_status(400, {}, {})
def test_raise_for_status_200(self): try: sansio.raise_for_status(200, {}, {}) except Exception as exc: raise pytest.fail("RAISE {}".format(exc))