def test_the_instance_should_be_able_to_update_a_registered_realm():
    driver = RespectfulWebdriver(webdriver=webdriver)

    driver.register_realm("TEST123", max_requests=100, timespan=300)
    driver.update_realm("TEST123", max_requests=1000, timespan=3000)

    assert driver.realm_max_requests("TEST123") == 1000
    assert driver.realm_timespan("TEST123") == 3000

    driver.unregister_realm("TEST123")
def test_the_instance_should_be_able_to_determine_if_it_can_perform_a_request_for_a_registered_realm(
):
    driver = RespectfulWebdriver(webdriver=webdriver)

    driver.register_realm("TEST123", max_requests=1000, timespan=5)

    assert driver._can_perform_get("TEST123")

    driver.update_realm("TEST123", max_requests=0)

    assert not driver._can_perform_get("TEST123")

    driver.unregister_realm("TEST123")
def test_the_instance_should_ignore_invalid_values_when_updating_a_realm():
    driver = RespectfulWebdriver(webdriver=webdriver)

    driver.register_realm("TEST123", max_requests=100, timespan=300)
    driver.update_realm("TEST123",
                        max_requests="FOO",
                        timespan="BAR",
                        fake=True)

    assert driver.realm_max_requests("TEST123") == 100
    assert driver.realm_timespan("TEST123") == 300

    driver.unregister_realm("TEST123")
def test_the_instance_should_return_a_rate_limit_exception_if_the_request_is_not_allowed_on_one_or_multiple_registered_realms(
):
    driver = RespectfulWebdriver(webdriver=webdriver)

    driver.register_realm("TEST123", max_requests=0, timespan=5)
    driver.register_realm("TEST234", max_requests=0, timespan=5)

    with pytest.raises(SeleniumRespectfulRateLimitedError):
        driver.get("http://google.com", realms=["TEST123", "TEST234"])

    driver.update_realm("TEST123", max_requests=10)

    with pytest.raises(SeleniumRespectfulRateLimitedError):
        driver.get("http://google.com", realms=["TEST123", "TEST234"])

    driver.update_realm("TEST123", max_requests=0)
    driver.update_realm("TEST234", max_requests=10)

    with pytest.raises(SeleniumRespectfulRateLimitedError):
        driver.get("http://google.com", realms=["TEST123", "TEST234"])

    driver.unregister_realm("TEST123")
    driver.unregister_realm("TEST234")