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:
@@ -37,22 +37,22 @@ class AssetTrackingTester:
|
||||
"name": "family_photo_1.jpg",
|
||||
"updated": "2024-01-01T10:00:00Z",
|
||||
"size": 1024000,
|
||||
"mimeType": "image/jpeg"
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
{
|
||||
"id": "asset_002",
|
||||
"name": "birthday_party.jpg",
|
||||
"updated": "2024-01-02T15:30:00Z",
|
||||
"size": 2048000,
|
||||
"mimeType": "image/jpeg"
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
{
|
||||
"id": "asset_003",
|
||||
"name": "school_event.png",
|
||||
"updated": "2024-01-03T09:15:00Z",
|
||||
"size": 1536000,
|
||||
"mimeType": "image/png"
|
||||
}
|
||||
"mimeType": "image/png",
|
||||
},
|
||||
]
|
||||
|
||||
self.mock_assets_v2 = [
|
||||
@@ -62,7 +62,7 @@ class AssetTrackingTester:
|
||||
"name": "family_photo_1.jpg",
|
||||
"updated": "2024-01-01T10:00:00Z",
|
||||
"size": 1024000,
|
||||
"mimeType": "image/jpeg"
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
# Existing asset - modified
|
||||
{
|
||||
@@ -70,7 +70,7 @@ class AssetTrackingTester:
|
||||
"name": "birthday_party.jpg",
|
||||
"updated": "2024-01-05T16:45:00Z", # Updated timestamp
|
||||
"size": 2100000, # Different size
|
||||
"mimeType": "image/jpeg"
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
# Existing asset - unchanged
|
||||
{
|
||||
@@ -78,7 +78,7 @@ class AssetTrackingTester:
|
||||
"name": "school_event.png",
|
||||
"updated": "2024-01-03T09:15:00Z",
|
||||
"size": 1536000,
|
||||
"mimeType": "image/png"
|
||||
"mimeType": "image/png",
|
||||
},
|
||||
# New asset
|
||||
{
|
||||
@@ -86,8 +86,8 @@ class AssetTrackingTester:
|
||||
"name": "new_vacation_photo.jpg",
|
||||
"updated": "2024-01-06T14:20:00Z",
|
||||
"size": 3072000,
|
||||
"mimeType": "image/jpeg"
|
||||
}
|
||||
"mimeType": "image/jpeg",
|
||||
},
|
||||
]
|
||||
|
||||
def test_basic_tracking(self):
|
||||
@@ -111,7 +111,7 @@ class AssetTrackingTester:
|
||||
# Simulate downloading first batch
|
||||
print("\n2. Simulating download of first batch...")
|
||||
for asset in self.mock_assets_v1:
|
||||
filename = asset['name']
|
||||
filename = asset["name"]
|
||||
filepath = Path(temp_dir) / filename
|
||||
|
||||
# Create dummy file
|
||||
@@ -149,7 +149,7 @@ class AssetTrackingTester:
|
||||
# Simulate first batch download
|
||||
print("1. Simulating initial download...")
|
||||
for asset in self.mock_assets_v1:
|
||||
filename = asset['name']
|
||||
filename = asset["name"]
|
||||
filepath = Path(temp_dir) / filename
|
||||
filepath.write_text(f"Mock content for {asset['id']}")
|
||||
tracker.mark_asset_downloaded(asset, filepath, True)
|
||||
@@ -163,16 +163,22 @@ class AssetTrackingTester:
|
||||
|
||||
# Should detect 1 modified + 1 new = 2 assets
|
||||
expected = 2 # asset_002 (modified) + asset_004 (new)
|
||||
assert len(new_assets) == expected, f"Expected {expected} assets, got {len(new_assets)}"
|
||||
assert len(new_assets) == expected, (
|
||||
f"Expected {expected} assets, got {len(new_assets)}"
|
||||
)
|
||||
|
||||
# Check which assets were detected
|
||||
detected_ids = [asset['id'] for asset in new_assets]
|
||||
detected_ids = [asset["id"] for asset in new_assets]
|
||||
print(f" Detected asset IDs: {detected_ids}")
|
||||
|
||||
assert 'asset_002' in detected_ids, "Modified asset_002 should be detected"
|
||||
assert 'asset_004' in detected_ids, "New asset_004 should be detected"
|
||||
assert 'asset_001' not in detected_ids, "Unchanged asset_001 should not be detected"
|
||||
assert 'asset_003' not in detected_ids, "Unchanged asset_003 should not be detected"
|
||||
assert "asset_002" in detected_ids, "Modified asset_002 should be detected"
|
||||
assert "asset_004" in detected_ids, "New asset_004 should be detected"
|
||||
assert "asset_001" not in detected_ids, (
|
||||
"Unchanged asset_001 should not be detected"
|
||||
)
|
||||
assert "asset_003" not in detected_ids, (
|
||||
"Unchanged asset_003 should not be detected"
|
||||
)
|
||||
|
||||
print(" ✅ Correctly identified 1 modified + 1 new asset")
|
||||
print("✅ Modified asset detection test passed!")
|
||||
@@ -190,7 +196,7 @@ class AssetTrackingTester:
|
||||
print("1. Creating and tracking assets...")
|
||||
filepaths = []
|
||||
for asset in self.mock_assets_v1:
|
||||
filename = asset['name']
|
||||
filename = asset["name"]
|
||||
filepath = Path(temp_dir) / filename
|
||||
filepath.write_text(f"Mock content for {asset['id']}")
|
||||
tracker.mark_asset_downloaded(asset, filepath, True)
|
||||
@@ -222,8 +228,12 @@ class AssetTrackingTester:
|
||||
print(f" Missing files: {stats_after['missing_files']}")
|
||||
|
||||
# Verify cleanup worked
|
||||
assert stats_after['missing_files'] == 0, "Should have no missing files after cleanup"
|
||||
assert stats_after['total_tracked_assets'] == len(self.mock_assets_v1) - 1, "Should have one less tracked asset"
|
||||
assert stats_after["missing_files"] == 0, (
|
||||
"Should have no missing files after cleanup"
|
||||
)
|
||||
assert (
|
||||
stats_after["total_tracked_assets"] == len(self.mock_assets_v1) - 1
|
||||
), "Should have one less tracked asset"
|
||||
|
||||
print(" ✅ Cleanup successfully removed missing file metadata")
|
||||
print("✅ Cleanup functionality test passed!")
|
||||
@@ -246,7 +256,7 @@ class AssetTrackingTester:
|
||||
list_endpoint="/v1/media/list",
|
||||
download_endpoint="/v1/media",
|
||||
output_dir=temp_dir,
|
||||
track_assets=True
|
||||
track_assets=True,
|
||||
)
|
||||
|
||||
# Check if asset tracker was initialized
|
||||
@@ -255,7 +265,9 @@ class AssetTrackingTester:
|
||||
|
||||
# Test tracker stats
|
||||
stats = downloader.asset_tracker.get_stats()
|
||||
print(f" Initial stats: {stats['total_tracked_assets']} tracked assets")
|
||||
print(
|
||||
f" Initial stats: {stats['total_tracked_assets']} tracked assets"
|
||||
)
|
||||
else:
|
||||
print(" ❌ Asset tracker was not initialized")
|
||||
|
||||
@@ -283,6 +295,7 @@ class AssetTrackingTester:
|
||||
except Exception as e:
|
||||
print(f"\n❌ TEST FAILED: {e}")
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
return False
|
||||
|
||||
@@ -310,7 +323,7 @@ async def test_with_real_api():
|
||||
email=email,
|
||||
password=password,
|
||||
track_assets=True,
|
||||
max_concurrent=2 # Limit for testing
|
||||
max_concurrent=2, # Limit for testing
|
||||
)
|
||||
|
||||
print("\n1. First run - downloading all assets...")
|
||||
@@ -324,20 +337,23 @@ async def test_with_real_api():
|
||||
print(f" Total size: {stats1['total_size_mb']} MB")
|
||||
|
||||
print("\n2. Second run - should find no new assets...")
|
||||
downloader.stats = {'total': 0, 'successful': 0, 'failed': 0, 'skipped': 0}
|
||||
downloader.stats = {"total": 0, "successful": 0, "failed": 0, "skipped": 0}
|
||||
await downloader.download_all_assets()
|
||||
|
||||
if downloader.asset_tracker:
|
||||
stats2 = downloader.asset_tracker.get_stats()
|
||||
print(f"\nSecond run statistics:")
|
||||
print(f" New downloads: {downloader.stats['successful']}")
|
||||
print(f" Skipped (unchanged): {len(stats2.get('total_tracked_assets', 0))}")
|
||||
print(
|
||||
f" Skipped (unchanged): {len(stats2.get('total_tracked_assets', 0))}"
|
||||
)
|
||||
|
||||
print("\n✅ Real API test completed!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Real API test failed: {e}")
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
@@ -346,7 +362,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 = AssetTrackingTester()
|
||||
@@ -355,7 +371,7 @@ def main():
|
||||
success = tester.run_all_tests()
|
||||
|
||||
# Ask user if they want to run real API test
|
||||
if success and len(sys.argv) > 1 and sys.argv[1] == '--real-api':
|
||||
if success and len(sys.argv) > 1 and sys.argv[1] == "--real-api":
|
||||
print("\n" + "🌐 Running real API test...")
|
||||
asyncio.run(test_with_real_api())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user