File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -362,11 +362,16 @@ def test_get_flags_for_identities_with_cache(
362362 headers = {SDK_ENVIRONMENT_KEY_HEADER : project_two_environment .api_key }
363363 )
364364
365+ # Fetch flags for both environments once to warm the cache
366+ environment_one_response = environment_one_client .get (url )
367+ assert environment_one_response .status_code == status .HTTP_200_OK
368+
369+ project_two_environment_response = project_two_environment_client .get (url )
370+ assert project_two_environment_response .status_code == status .HTTP_200_OK
371+
365372 # When
366- # We hit the flags endpoint 10 times for each identity
367- # Only the first request per environment should trigger database queries
368- with django_assert_num_queries (20 ): # 2 identities × 10 queries each
369- for _ in range (100 ):
373+ with django_assert_num_queries (0 ):
374+ for _ in range (10 ):
370375 environment_one_response = environment_one_client .get (url )
371376 assert environment_one_response .status_code == status .HTTP_200_OK
372377
Original file line number Diff line number Diff line change @@ -817,12 +817,16 @@ def test_get_flags_cache(
817817 project_two_environment_client = APIClient (
818818 headers = {SDK_ENVIRONMENT_KEY_HEADER : project_two_environment .api_key }
819819 )
820+ # Fetch flags for both environments once to warm the cache
821+ environment_one_response = environment_one_client .get (url )
822+ assert environment_one_response .status_code == status .HTTP_200_OK
823+
824+ project_two_environment_response = project_two_environment_client .get (url )
825+ assert project_two_environment_response .status_code == status .HTTP_200_OK
820826
821827 # When
822- # We hit the flags endpoint 10 times for each environment
823- # Only the first request per environment should trigger database queries
824- with django_assert_num_queries (4 ): # 2 environments × 2 queries each
825- for _ in range (100 ):
828+ with django_assert_num_queries (0 ):
829+ for _ in range (10 ):
826830 environment_one_response = environment_one_client .get (url )
827831 assert environment_one_response .status_code == status .HTTP_200_OK
828832
You can’t perform that action at this time.
0 commit comments