Exemplo n.º 1
0
def test_datarequest_elapsed_time_use_current_time(freezer):
    data_request = _DataRequest(timeout=10)
    freezer.move_to("2018-09-07 16:35:05")
    assert data_request.elapsed_time() == 5
Exemplo n.º 2
0
def test_datarequest_get_exception_when_ready():
    exception = Exception()
    data_request = _DataRequest(timeout=10)
    data_request.exception = exception

    assert data_request.exception == exception
Exemplo n.º 3
0
def test_datarequest_create_at_use_current_time(freezer):
    data_request = _DataRequest(timeout=10)
    assert data_request._create_at == time.time()
Exemplo n.º 4
0
def test_datarequest_exception_raise_notready_when_not_ready():
    data_request = _DataRequest(timeout=10)

    with pytest.raises(DataRequestNotReady):
        data_request.exception
Exemplo n.º 5
0
def test_datarequest_raise_exception_on_output_if_has_exception():
    data_request = _DataRequest(timeout=10)
    data_request.exception = ValueError()

    with pytest.raises(ValueError):
        data_request.output
Exemplo n.º 6
0
def test_datarequest_set_ready_false_by_default():
    data_request = _DataRequest(timeout=10)

    assert data_request.ready is False
Exemplo n.º 7
0
def test_datarequest_outout_raise_notready_when_not_ready():
    data_request = _DataRequest(timeout=10)

    with pytest.raises(DataRequestNotReady):
        data_request.output
Exemplo n.º 8
0
def test_datarequest_get_output_when_ready():
    data_request = _DataRequest(timeout=10)
    data_request.output = "output_data"

    assert data_request.output == "output_data"
Exemplo n.º 9
0
def test_datarequest_set_ready_true_when_output():
    data_request = _DataRequest(timeout=10)
    data_request.output = "output_data"

    assert data_request.ready is True
Exemplo n.º 10
0
def test_datarequest_exception_set_latency_time(freezer):
    data_request = _DataRequest(timeout=5)
    freezer.move_to("2018-09-07 16:35:00.200")
    data_request.exception = Exception()
    assert data_request.latency == pytest.approx(0.2)
Exemplo n.º 11
0
def test_datarequest_output_set_latency_time(freezer):
    data_request = _DataRequest(timeout=5)
    freezer.move_to("2018-09-07 16:35:00.200")
    data_request.output = "foo"
    assert data_request.latency == pytest.approx(0.2)
Exemplo n.º 12
0
def test_datarequest_latency_is_none_by_default():
    data_request = _DataRequest(timeout=5)
    assert data_request.latency is None
Exemplo n.º 13
0
def test_datarequest_elapsed_time_is_in_s(freezer):
    data_request = _DataRequest(timeout=5)
    freezer.move_to("2018-09-07 16:35:00.200")
    assert data_request.elapsed_time() == pytest.approx(0.2)
Exemplo n.º 14
0
def test_datarequest_ttl_is_in_s(freezer):
    data_request = _DataRequest(timeout=5)
    freezer.move_to("2018-09-07 16:35:00.100")
    assert data_request.ttl() == pytest.approx(4.9)