Exemplo n.º 1
0
def test_resample(app, fake_samples):
    latest = Sample.latest(limit=10)
    assert len(latest) == 10
    ts = Sample.timeseries(latest)
    assert list(ts) == [s.temp for s in latest]
    tmin, tmax = min(ts.index), max(ts.index)
    assert tmin < tmax
    assert END_TIME - timedelta(minutes=104) <= tmin < END_TIME - timedelta(
        minutes=96)
    assert END_TIME - timedelta(minutes=14) <= tmax < END_TIME - timedelta(
        minutes=6)
    resampled = ts.resample("60S")
    assert 82 <= len(resampled.mean().index) <= 98
    assert all([40 <= t <= 80 for t in resampled.interpolate(method="linear")])
Exemplo n.º 2
0
def test_read_write_temp(mock_mpl115, app, fake_states):
    mock_mpl115.read.return_value = (10, 10)
    cli._poll_once()
    mock_mpl115.read.assert_called_once()
    assert Sample.latest().temp == 10