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.

8 Examples 7

Example 1

View license
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

View license
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 3

View license
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 4

View license
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 5

View license
@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 6

View license
@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 7

View license
@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')

Example 8

View license
@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')