requests_middleware.contrib.throttleware.ThrottleError

Here are the examples of the python api requests_middleware.contrib.throttleware.ThrottleError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

Example 1

Project: requests-middleware Source File: test_throttle.py
def test_throttle_delay(throttle_delay, monkeypatch):
    throttle_delay.check(None)
    throttle_delay.store(None, None, None)
    with pytest.raises(throttleware.ThrottleError):
        throttle_delay.check(None)
    now = datetime.datetime.utcnow() + relativedelta(seconds=6)
    utils.mock_datetime(monkeypatch, utcnow=now)
    throttle_delay.check(None)

Example 2

Project: requests-middleware Source File: test_throttle.py
def test_throttle_per_hour(throttle_per_hour, monkeypatch):
    for _ in range(5):
        throttle_per_hour.check(None)
        throttle_per_hour.store(None, None, None)
    with pytest.raises(throttleware.ThrottleError):
        throttle_per_hour.check(None)
    now = datetime.datetime.utcnow() + relativedelta(hours=2)
    utils.mock_datetime(monkeypatch, utcnow=now)
    throttle_per_hour.check(None)

Example 3

Project: requests-middleware Source File: test_throttle.py
@pytest.mark.httpretty
def test_throttle_delay_integration(throttle_delay_session, page_fixture,
                                    monkeypatch):
    throttle_delay_session.get('http://test.com/page')
    with pytest.raises(throttleware.ThrottleError):
        throttle_delay_session.get('http://test.com/page')
    now = datetime.datetime.utcnow() + relativedelta(seconds=6)
    utils.mock_datetime(monkeypatch, utcnow=now)
    throttle_delay_session.get('http://test.com/page')

Example 4

Project: requests-middleware Source File: test_throttle.py
@pytest.mark.httpretty
def test_throttle_per_hour_integration(throttle_per_hour_session, page_fixture,
                                       monkeypatch):
    for _ in range(5):
        throttle_per_hour_session.get('http://test.com/page')
    with pytest.raises(throttleware.ThrottleError):
        throttle_per_hour_session.get('http://test.com/page')
    now = datetime.datetime.utcnow() + relativedelta(hours=2)
    utils.mock_datetime(monkeypatch, utcnow=now)
    throttle_per_hour_session.get('http://test.com/page')