예제 #1
0
def test_create_logwriter(mode, tmp_path, calibration_data):
    d = tmp_path / f"{ mode }.h5"
    h = LogWriter(store_path=d, calibration_data=calibration_data, mode=mode)
    assert not d.exists()
    h.__enter__()
    assert d.exists()
    h.__exit__()
예제 #2
0
def test_create_logwriter_with_force(tmp_path, calibration_data):
    d = tmp_path / "harvest.h5"
    d.touch()
    stat = d.stat()
    time.sleep(0.1)

    h = LogWriter(store_path=d, calibration_data=calibration_data, force_overwrite=False)
    h.__enter__()
    h.__exit__()
    # This should have created the following alternative file:
    d_altered = tmp_path / "harvest.0.h5"
    assert h.store_path == d_altered
    assert d_altered.exists()

    h = LogWriter(store_path=d, calibration_data=calibration_data, force_overwrite=True)
    h.__enter__()
    h.__exit__()
    new_stat = d.stat()
    assert new_stat.st_mtime > stat.st_mtime