mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-16 04:58:01 +00:00
Fix local performance tests: Handle Django redirects properly
- Add follow=True to Django test client requests to handle redirects
- Fix content length handling for FileResponse objects
- Local performance tests now pass correctly showing ✅ status
This resolves the issue where all avatar generation tests were showing
'Failed' status even though they were working correctly.
This commit is contained in:
@@ -191,7 +191,7 @@ class PerformanceTestRunner:
|
||||
# Local testing with Django test client
|
||||
if self.client is None:
|
||||
raise RuntimeError("Django test client not initialized")
|
||||
response = self.client.get(url_path)
|
||||
response = self.client.get(url_path, follow=True)
|
||||
end_time = time.time()
|
||||
duration = (end_time - start_time) * 1000
|
||||
|
||||
@@ -207,11 +207,19 @@ class PerformanceTestRunner:
|
||||
else:
|
||||
cache_status = "miss" # Default assumption for first generation
|
||||
|
||||
# Handle content length for different response types
|
||||
content_length = 0
|
||||
if hasattr(response, "content"):
|
||||
content_length = len(response.content) if response.content else 0
|
||||
elif hasattr(response, "streaming_content"):
|
||||
# For FileResponse, we can't easily get content length without consuming the stream
|
||||
content_length = 1 # Just indicate there's content
|
||||
|
||||
return {
|
||||
"test": f"{case['default']}_{case['size']}px",
|
||||
"duration_ms": duration,
|
||||
"status_code": response.status_code,
|
||||
"content_length": len(response.content) if response.content else 0,
|
||||
"content_length": content_length,
|
||||
"cache_status": cache_status,
|
||||
"success": response.status_code == 200,
|
||||
"full_url": full_url,
|
||||
|
||||
Reference in New Issue
Block a user