Example #1
0
def test_tmpfs_mount_no_dump(site_context, monkeypatch):
    tmp_dir = Path(site_context.tmp_dir)
    tmp_dir.mkdir(parents=True, exist_ok=True)

    # Ensure that no dump exists and then execute the restore operation
    assert not omdlib.tmpfs._tmpfs_dump_path(site_context).exists()
    restore_tmpfs_dump(site_context)
    assert list(tmp_dir.iterdir()) == []
Example #2
0
def test_tmpfs_restore_with_tmpfs(site_context, monkeypatch, not_restored_file):
    tmp_files = _prepare_tmpfs(site_context)

    # Now perform unmount call and test result
    assert not omdlib.tmpfs._tmpfs_dump_path(site_context).exists()
    omdlib.tmpfs.unmount_tmpfs(site_context)
    for tmp_file in tmp_files:
        assert not tmp_file.exists()

    assert omdlib.tmpfs._tmpfs_dump_path(site_context).exists()
    restore_tmpfs_dump(site_context)
    for tmp_file in tmp_files:
        assert tmp_file.exists()

    # Test that out-of-scope files are not restored
    assert not not_restored_file.exists()
Example #3
0
def test_tmpfs_restore_no_tmpfs(site_context, monkeypatch, not_restored_file):
    # Use rm logic in unmount_tmpfs instead of unmount
    monkeypatch.setattr(omdlib.tmpfs, "tmpfs_mounted", lambda x: False)

    tmp_files = _prepare_tmpfs(site_context)

    # Now perform unmount call and test result
    assert not omdlib.tmpfs._tmpfs_dump_path(site_context).exists()
    unmount_tmpfs(site_context)
    for tmp_file in tmp_files:
        assert not tmp_file.exists()

    assert omdlib.tmpfs._tmpfs_dump_path(site_context).exists()
    restore_tmpfs_dump(site_context)
    for tmp_file in tmp_files:
        assert tmp_file.exists()

    # Test that out-of-scope files are not restored
    assert not not_restored_file.exists()