- test_atomic_settings.py: Atomic write operation tests - test_csv_quoting.py: CSV QUOTE_MINIMAL protection tests - test_complete_csv_sanitization.py: Full field sanitization tests - test_input_sanitization.py: Input validation and security tests - test_alternating_colors.py: Visual enhancement tests - test_mark_billed.py & test_mark_logic.py: Existing functionality tests All tests passing with comprehensive security coverage.
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# Test script to verify the mark as billed functionality
|
|
import csv
|
|
from datetime import datetime, date
|
|
|
|
def test_mark_billed_logic():
|
|
"""Test the logic for marking entries as billed"""
|
|
|
|
# Simulate filtered data from report
|
|
filtered_data = [
|
|
{'Job': 'Development', 'Customer': 'Client Corp', 'Date': '2025-10-01', 'Hours': '4.5'},
|
|
{'Job': 'Development', 'Customer': 'Client Corp', 'Date': '2025-10-02', 'Hours': '6.0'},
|
|
{'Job': 'Development', 'Customer': 'Client Corp', 'Date': '2025-10-03', 'Hours': '3.5'},
|
|
{'Job': 'Development', 'Customer': 'Client Corp', 'Date': '2025-10-05', 'Hours': '5.0'}
|
|
]
|
|
|
|
# Read current archive
|
|
all_data = []
|
|
with open("time_tracker_archive.csv", 'r', encoding='utf-8') as csvfile:
|
|
reader = csv.DictReader(csvfile)
|
|
fieldnames = reader.fieldnames
|
|
|
|
for row in reader:
|
|
# Check if this row matches filtered data
|
|
is_in_report = False
|
|
for report_row in filtered_data:
|
|
if (row['Customer'] == report_row['Customer'] and
|
|
row['Date'] == report_row['Date'] and
|
|
row['Job'] == report_row['Job'] and
|
|
row['Hours'] == report_row['Hours']):
|
|
is_in_report = True
|
|
break
|
|
|
|
if is_in_report:
|
|
# This row is included in report, mark as billed
|
|
row['Billed'] = 'True'
|
|
|
|
all_data.append(row)
|
|
|
|
# Count billed entries
|
|
billed_count = sum(1 for row in all_data if row['Billed'] == 'True')
|
|
unbilled_count = sum(1 for row in all_data if row['Billed'] == 'false')
|
|
|
|
print(f"Test Report Data: {len(filtered_data)} entries")
|
|
print(f"Billed after marking: {billed_count} entries")
|
|
print(f"Remaining unbilled: {unbilled_count} entries")
|
|
print()
|
|
|
|
# Show what would be billed
|
|
for row in all_data:
|
|
if row['Billed'] == 'True':
|
|
print(f"✓ Billed: {row['Customer']} - {row['Job']} ({row['Hours']}h on {row['Date']})")
|
|
|
|
return len(filtered_data) == billed_count
|
|
|
|
if __name__ == "__main__":
|
|
print("Testing Mark as Billed logic...")
|
|
success = test_mark_billed_logic()
|
|
print(f"\nTest {'PASSED' if success else 'FAILED'}")
|
|
|
|
if success:
|
|
print("\nThe mark as billed functionality is working correctly!")
|
|
print("You can now test it in the actual application.") |