-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_basic1.py
More file actions
49 lines (39 loc) · 1.46 KB
/
test_basic1.py
File metadata and controls
49 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# test_basic.py
"""Basic functionality test for NinjaZipPy"""
from ninjazipy import BitFileExtractor, BitFileCompressor
from pathlib import Path
def test_basic_functionality():
"""Test basic compression and extraction using a fixed directory."""
# Use a fixed folder to retain files after test for manual check
temp_path = Path(r"C:\Users\moham\Desktop\NinjaZipPyDebug")
temp_path.mkdir(parents=True, exist_ok=True)
# Create test file
test_file = temp_path / "test.txt"
test_file.write_text("Hello, NinjaZipPy!")
# Create archive
archive_path = temp_path / "test.7z"
compressor = BitFileCompressor()
compressor.compress_files([str(test_file)], str(archive_path))
print(f"✅ Created archive: {archive_path}")
# Extract archive
extract_dir = temp_path / "extracted"
extractor = BitFileExtractor()
extractor.extract(str(archive_path), str(extract_dir))
print(f"✅ Extracted to: {extract_dir}")
# Verify extraction
extracted_file = extract_dir / "test.txt"
if extracted_file.exists():
content = extracted_file.read_text()
print(f"✅ Content verified: {content}")
return True
else:
print("❌ Extraction failed")
return False
if __name__ == "__main__":
try:
if test_basic_functionality():
print("🎉 All tests passed!")
else:
print("❌ Test failed!")
except Exception as e:
print(f"❌ Test failed: {e}")