From 5556f7bd9a2b64f5fe2892437c6c68c1d50e11d7 Mon Sep 17 00:00:00 2001 From: Oliver Falk Date: Thu, 23 Oct 2025 19:07:23 +0200 Subject: [PATCH] Fix local performance tests: Handle Django redirects properly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- scripts/performance_tests.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/performance_tests.py b/scripts/performance_tests.py index c83f937..baaf1e5 100644 --- a/scripts/performance_tests.py +++ b/scripts/performance_tests.py @@ -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,