Beispiel #1
0
def simple_timeseries():
    return Timeseries([1, 2, 3, 4, 5])
Beispiel #2
0
def test_timeseries_conversion_no_sequence():
    with pytest.raises(ValueError):
        empty_timeseries = Timeseries([])
        empty_timeseries.convert_to_snapshot_sequence(3)
Beispiel #3
0

@pytest.fixture
def mock_response_ok():
    return MockResponse(200, {'daily': {'data': [{'time': START_TIME}]}})


@pytest.fixture
def simple_timeseries():
    return Timeseries([1, 2, 3, 4, 5])


@pytest.mark.parametrize(
    'timeseries, memory_length, expected_snapshot_sequence',
    [
        (Timeseries([1, 2, 3, 4, 5]), 1, [[1, 2], [2, 3], [3, 4], [4, 5]]),
        (Timeseries([1, 2, 3, 4, 5]), 2, [[1, 2, 3], [2, 3, 4], [3, 4, 5]]),
        (Timeseries([1, 2, 3, 4, 5]), 4, [[1, 2, 3, 4, 5]]),
    ],
)
def test_timeseries_conversion_ok(timeseries, memory_length,
                                  expected_snapshot_sequence):
    assert timeseries.convert_to_snapshot_sequence(
        memory_length) == expected_snapshot_sequence


def test_timeseries_conversion_no_sequence():
    with pytest.raises(ValueError):
        empty_timeseries = Timeseries([])
        empty_timeseries.convert_to_snapshot_sequence(3)