Ejemplo n.º 1
0
def test_defaults(sleep, uniform):
    from google.cloud.firestore_v1.transaction import _sleep

    curr_sleep = 10.0
    assert uniform.return_value <= curr_sleep

    new_sleep = _sleep(curr_sleep)
    assert new_sleep == 2.0 * curr_sleep

    uniform.assert_called_once_with(0.0, curr_sleep)
    sleep.assert_called_once_with(uniform.return_value)
Ejemplo n.º 2
0
def test_explicit(sleep, uniform):
    from google.cloud.firestore_v1.transaction import _sleep

    curr_sleep = 12.25
    assert uniform.return_value <= curr_sleep

    multiplier = 1.5
    new_sleep = _sleep(curr_sleep, max_sleep=100.0, multiplier=multiplier)
    assert new_sleep == multiplier * curr_sleep

    uniform.assert_called_once_with(0.0, curr_sleep)
    sleep.assert_called_once_with(uniform.return_value)
Ejemplo n.º 3
0
def test_exceeds_max(sleep, uniform):
    from google.cloud.firestore_v1.transaction import _sleep

    curr_sleep = 20.0
    assert uniform.return_value <= curr_sleep

    max_sleep = 38.5
    new_sleep = _sleep(curr_sleep, max_sleep=max_sleep, multiplier=2.0)
    assert new_sleep == max_sleep

    uniform.assert_called_once_with(0.0, curr_sleep)
    sleep.assert_called_once_with(uniform.return_value)
Ejemplo n.º 4
0
    def _call_fut(current_sleep, **kwargs):
        from google.cloud.firestore_v1.transaction import _sleep

        return _sleep(current_sleep, **kwargs)