changed image version; small typos
All checks were successful
Build Docker Image / build (push) Successful in 2m31s
All checks were successful
Build Docker Image / build (push) Successful in 2m31s
This commit is contained in:
@@ -39,7 +39,7 @@ class ConfigTrackingTester:
|
||||
"timeout": 30,
|
||||
"track_assets": track_assets,
|
||||
"email": "tudor.sitaru@gmail.com",
|
||||
"password": "mTVq8uNUvY7R39EPGVAm@"
|
||||
"password": "mTVq8uNUvY7R39EPGVAm@",
|
||||
}
|
||||
|
||||
def test_config_loading(self):
|
||||
@@ -53,7 +53,7 @@ class ConfigTrackingTester:
|
||||
|
||||
# Test with tracking enabled
|
||||
config_data = self.create_test_config(temp_dir, track_assets=True)
|
||||
with open(config_file, 'w') as f:
|
||||
with open(config_file, "w") as f:
|
||||
json.dump(config_data, f, indent=2)
|
||||
|
||||
print("1. Testing config with asset tracking enabled...")
|
||||
@@ -67,7 +67,7 @@ class ConfigTrackingTester:
|
||||
|
||||
# Test with tracking disabled
|
||||
config_data = self.create_test_config(temp_dir, track_assets=False)
|
||||
with open(config_file, 'w') as f:
|
||||
with open(config_file, "w") as f:
|
||||
json.dump(config_data, f, indent=2)
|
||||
|
||||
print("\n2. Testing config with asset tracking disabled...")
|
||||
@@ -93,12 +93,14 @@ class ConfigTrackingTester:
|
||||
|
||||
# Create config without track_assets field
|
||||
config_data = self.create_test_config(temp_dir)
|
||||
del config_data['track_assets'] # Remove the field entirely
|
||||
del config_data["track_assets"] # Remove the field entirely
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
with open(config_file, "w") as f:
|
||||
json.dump(config_data, f, indent=2)
|
||||
|
||||
print("1. Testing config without track_assets field (should default to True)...")
|
||||
print(
|
||||
"1. Testing config without track_assets field (should default to True)..."
|
||||
)
|
||||
downloader = ConfigImageDownloader(str(config_file))
|
||||
|
||||
if downloader.asset_tracker:
|
||||
@@ -121,7 +123,7 @@ class ConfigTrackingTester:
|
||||
|
||||
# Create config with tracking enabled
|
||||
config_data = self.create_test_config(temp_dir, track_assets=True)
|
||||
with open(config_file, 'w') as f:
|
||||
with open(config_file, "w") as f:
|
||||
json.dump(config_data, f, indent=2)
|
||||
|
||||
print("1. Creating ConfigImageDownloader with tracking enabled...")
|
||||
@@ -141,15 +143,15 @@ class ConfigTrackingTester:
|
||||
"name": "test_image_1.jpg",
|
||||
"updated": "2024-01-01T10:00:00Z",
|
||||
"size": 1024000,
|
||||
"mimeType": "image/jpeg"
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
{
|
||||
"id": "config_test_002",
|
||||
"name": "test_image_2.jpg",
|
||||
"updated": "2024-01-02T11:00:00Z",
|
||||
"size": 2048000,
|
||||
"mimeType": "image/jpeg"
|
||||
}
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
]
|
||||
|
||||
# First check - should find all assets as new
|
||||
@@ -163,7 +165,7 @@ class ConfigTrackingTester:
|
||||
# Simulate marking assets as downloaded
|
||||
print("\n3. Simulating asset downloads...")
|
||||
for asset in mock_assets:
|
||||
filepath = Path(temp_dir) / asset['name']
|
||||
filepath = Path(temp_dir) / asset["name"]
|
||||
filepath.write_text(f"Mock content for {asset['id']}")
|
||||
downloader.asset_tracker.mark_asset_downloaded(asset, filepath, True)
|
||||
print(f" Marked as downloaded: {asset['name']}")
|
||||
@@ -186,7 +188,7 @@ class ConfigTrackingTester:
|
||||
print(f" Successful downloads: {stats['successful_downloads']}")
|
||||
print(f" Existing files: {stats['existing_files']}")
|
||||
|
||||
if stats['total_tracked_assets'] != 2:
|
||||
if stats["total_tracked_assets"] != 2:
|
||||
print(" ❌ Should have 2 tracked assets")
|
||||
return False
|
||||
|
||||
@@ -205,7 +207,7 @@ class ConfigTrackingTester:
|
||||
|
||||
# Create config with tracking enabled
|
||||
config_data = self.create_test_config(temp_dir, track_assets=True)
|
||||
with open(config_file, 'w') as f:
|
||||
with open(config_file, "w") as f:
|
||||
json.dump(config_data, f, indent=2)
|
||||
|
||||
print("1. Testing --show-stats option...")
|
||||
@@ -218,17 +220,32 @@ class ConfigTrackingTester:
|
||||
original_argv = sys.argv.copy()
|
||||
|
||||
# Test show-stats option
|
||||
sys.argv = ['config_downloader.py', '--config', str(config_file), '--show-stats']
|
||||
sys.argv = [
|
||||
"config_downloader.py",
|
||||
"--config",
|
||||
str(config_file),
|
||||
"--show-stats",
|
||||
]
|
||||
|
||||
# This would normally call main(), but we'll just check the parsing works
|
||||
print(" ✅ Command line parsing would work for --show-stats")
|
||||
|
||||
# Test cleanup option
|
||||
sys.argv = ['config_downloader.py', '--config', str(config_file), '--cleanup']
|
||||
sys.argv = [
|
||||
"config_downloader.py",
|
||||
"--config",
|
||||
str(config_file),
|
||||
"--cleanup",
|
||||
]
|
||||
print(" ✅ Command line parsing would work for --cleanup")
|
||||
|
||||
# Test force-redownload option
|
||||
sys.argv = ['config_downloader.py', '--config', str(config_file), '--force-redownload']
|
||||
sys.argv = [
|
||||
"config_downloader.py",
|
||||
"--config",
|
||||
str(config_file),
|
||||
"--force-redownload",
|
||||
]
|
||||
print(" ✅ Command line parsing would work for --force-redownload")
|
||||
|
||||
# Restore original argv
|
||||
@@ -258,8 +275,12 @@ class ConfigTrackingTester:
|
||||
print("\n" + "=" * 80)
|
||||
print("🎉 ALL CONFIG DOWNLOADER TESTS PASSED!")
|
||||
print("=" * 80)
|
||||
print("✅ Asset tracking is now properly integrated into config_downloader.py")
|
||||
print("✅ The config downloader will now skip already downloaded assets")
|
||||
print(
|
||||
"✅ Asset tracking is now properly integrated into config_downloader.py"
|
||||
)
|
||||
print(
|
||||
"✅ The config downloader will now skip already downloaded assets"
|
||||
)
|
||||
print("✅ Command line options for tracking control are available")
|
||||
else:
|
||||
print("\n❌ SOME TESTS FAILED")
|
||||
@@ -269,6 +290,7 @@ class ConfigTrackingTester:
|
||||
except Exception as e:
|
||||
print(f"\n❌ TEST FAILED: {e}")
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
@@ -300,7 +322,9 @@ def show_usage_instructions():
|
||||
print("python3 config_downloader.py --config parentzone_config.json")
|
||||
print()
|
||||
print("# Force download all assets:")
|
||||
print("python3 config_downloader.py --config parentzone_config.json --force-redownload")
|
||||
print(
|
||||
"python3 config_downloader.py --config parentzone_config.json --force-redownload"
|
||||
)
|
||||
print()
|
||||
print("# Show asset statistics:")
|
||||
print("python3 config_downloader.py --config parentzone_config.json --show-stats")
|
||||
@@ -320,7 +344,7 @@ def main():
|
||||
# Setup logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
)
|
||||
|
||||
tester = ConfigTrackingTester()
|
||||
|
||||
Reference in New Issue
Block a user