-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_exclude_functionality.py
More file actions
123 lines (99 loc) · 3.64 KB
/
test_exclude_functionality.py
File metadata and controls
123 lines (99 loc) · 3.64 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"""
Test script to verify the exclude functionality for file uploads
"""
import sys
import os
# Add parent directory to path
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from core.models import PatientData, FileData, DataType
from core.api_client import TF4MAPIClient
def test_exclude_functionality():
"""Test that excluded files are not included in upload"""
print("=" * 60)
print("Testing Exclude Functionality")
print("=" * 60)
print()
# Create test patient data
patient = PatientData(
patient_id="TEST_EXCLUDE",
folder_path="C:/test"
)
# Add some test files with different types
patient.ios_upper = FileData(
path="C:/test/upper.stl",
data_type=DataType.IOS_UPPER
)
patient.ios_lower = FileData(
path="C:/test/lower.stl",
data_type=DataType.EXCLUDE # This should be excluded
)
patient.intraoral_photos = [
FileData(path="C:/test/photo1.jpg", data_type=DataType.INTRAORAL_PHOTO),
FileData(path="C:/test/photo2.jpg", data_type=DataType.EXCLUDE), # Excluded
FileData(path="C:/test/photo3.jpg", data_type=DataType.INTRAORAL_PHOTO),
]
patient.teleradiography = FileData(
path="C:/test/xray.jpg",
data_type=DataType.TELERADIOGRAPHY
)
patient.orthopantomography = FileData(
path="C:/test/panoramic.jpg",
data_type=DataType.EXCLUDE # This should be excluded
)
# Test the API client's file gathering
api_client = TF4MAPIClient("http://test.com", project_slug="maxillo")
files_to_upload = api_client._get_all_patient_files(patient)
print("Files to upload (after exclusion filtering):")
print("-" * 60)
expected_files = [
("upper.stl", "upper_scan_raw"),
("photo1.jpg", "intraoral_photos"),
("photo3.jpg", "intraoral_photos"),
("xray.jpg", "teleradiography"),
]
excluded_files = [
"lower.stl",
"photo2.jpg",
"panoramic.jpg"
]
# Check results
uploaded_count = 0
for file_data, field_name in files_to_upload:
print(f" ✓ {os.path.basename(file_data.path):20} → {field_name}")
uploaded_count += 1
print()
print(f"Total files to upload: {uploaded_count}")
print()
# Verify excluded files are not in the list
print("Verifying exclusions:")
print("-" * 60)
upload_paths = [os.path.basename(f[0].path) for f in files_to_upload]
all_correct = True
for excluded_file in excluded_files:
if excluded_file in upload_paths:
print(f" ❌ ERROR: {excluded_file} should be excluded but was found!")
all_correct = False
else:
print(f" ✓ {excluded_file:20} correctly excluded")
print()
# Summary
print("=" * 60)
if all_correct and uploaded_count == len(expected_files):
print("✅ All tests passed!")
print(f" - {uploaded_count} files will be uploaded")
print(f" - {len(excluded_files)} files correctly excluded")
else:
print("❌ Some tests failed!")
print("=" * 60)
print()
# Display feature summary
print("Exclude Feature Summary:")
print("-" * 60)
print("1. Added DataType.EXCLUDE to models.py")
print("2. Updated ReassignTypeDialog with 'Exclude from Upload' option")
print("3. API client filters out excluded files during upload")
print("4. Excluded files shown with 🚫 icon and gray text")
print("5. Files can be reassigned from any type to EXCLUDE")
print("-" * 60)
if __name__ == "__main__":
test_exclude_functionality()