feat: Initial commit for OnEver Drive centralized backup system with Windows PyQt6 agent and Proxmox LXC deployment
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import os
|
||||
import time
|
||||
import pytest
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from agent.scanner import is_file_locked, is_file_stable, DirectoryScanner
|
||||
|
||||
def test_file_lock_and_stability():
|
||||
"""
|
||||
Tests detection of file locks, growing files, and stable files.
|
||||
"""
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
test_file = Path(tmpdir) / "test_active.bak"
|
||||
test_file.write_text("initial data")
|
||||
|
||||
# 1. Stable file test
|
||||
# When file was modified now, with min_stable_seconds=0, it should be immediately stable
|
||||
assert is_file_stable(test_file, min_stable_seconds=0) == True
|
||||
|
||||
# 2. Scanner test with filter
|
||||
other_file = Path(tmpdir) / "ignored.txt"
|
||||
other_file.write_text("not a backup")
|
||||
|
||||
scanner = DirectoryScanner(tmpdir, file_patterns="*.bak", min_stable_seconds=0)
|
||||
found = scanner.scan()
|
||||
assert len(found) == 1
|
||||
assert found[0].name == "test_active.bak"
|
||||
|
||||
print("\n>>> File Lock & Scanner Test Passed!")
|
||||
Reference in New Issue
Block a user