def test_fs_observer_started_event_creates_rundir_with_filesystem_delay(
    dir_obs, sample_run, monkeypatch
):
    """Assumes listdir doesn't show existing file (e.g. due to caching or delay of network storage)"""
    basedir, obs = dir_obs
    sample_run["_id"] = None
    _id = obs.started_event(**sample_run)
    assert _id == "1"
    assert os.listdir(str(basedir)) == [_id]
    with monkeypatch.context() as m:
        m.setattr("os.listdir", lambda _: [])
        assert os.listdir(str(basedir)) == []
        _id2 = obs.started_event(**sample_run)
        assert _id2 == "2"
Assumes listdir doesn't show existing file (e.g. due to caching or delay of network storage)
tests/test_observers/test_file_storage_observer.py