Example #1
0
def test_old_db() -> None:
    from my.bluemaestro import measurements
    res = list(measurements())

    r1 = one(x for x in res if x.dt.strftime('%Y%m%d %H:%M:%S') == '20181003 09:07:00')
    r2 = one(x for x in res if x.dt.strftime('%Y%m%d %H:%M:%S') == '20181003 09:19:00')

    assert r1.temp == 16.8
    assert r2.temp == 18.3
    assert r1.pressure == 1025.8
    assert r2.pressure == 1009.9
Example #2
0
def test() -> None:
    from my.bluemaestro import measurements
    res2020 = [m for m in measurements() if '2020' in str(m.dt)]

    tp = [x for x in res2020 if x.temp == 2.1]
    assert len(tp) > 0
    for p in tp:
        print(p)
        dts = p.dt.strftime('%Y%m%d %H')
        # check that timezone is set properly
        assert dts == '20200824 22'

    assert len(tp) == 1  # should be unique

    # 2.5 K + 4 K datapoints, somwhat overlapping
    assert len(res2020) < 6000
Example #3
0
File: check.py Project: xdrie/HPI
def main() -> None:
    temps = list(measurements())
    latest = temps[:-2]

    prev = latest[-2].dt
    last = latest[-1].dt

    POINTS_STORED = 6000
    FREQ_SEC = 60
    SECS_STORED = POINTS_STORED * FREQ_SEC
    HOURS_STORED = POINTS_STORED / (60 * 60 / FREQ_SEC)  # around 4 days
    NOW = datetime.now()
    assert NOW - last < timedelta(hours=HOURS_STORED /
                                  2), f'old backup! {last}'

    assert last - prev < timedelta(minutes=3), f'bad interval! {last - prev}'
    single = (last - prev).seconds
Example #4
0
def test():
    print(list(measurements(_get_exports()[-1:])))