@@ -368,55 +368,6 @@ def test_shutdown_error_is_logged_but_continues(self, mock_get):
368368 # Shutdown was called
369369 self .assertEqual (self .cache_provider .shutdown_call_count , 1 )
370370
371- @mock .patch ("posthog.client.get" )
372- def test_handles_cache_data_missing_keys_gracefully (self , mock_get ):
373- """When cache returns data missing optional keys, should handle gracefully."""
374- self .cache_provider .should_fetch_return_value = False
375- # Missing 'cohorts' key - should use .get() default
376- self .cache_provider .stored_data = {
377- "flags" : [{"key" : "test-flag" , "active" : True , "filters" : {}}],
378- "group_type_mapping" : {"0" : "company" },
379- }
380-
381- client = self ._create_client_with_cache ()
382- client ._load_feature_flags ()
383-
384- # Should not call API
385- mock_get .assert_not_called ()
386-
387- # Flags should be loaded
388- self .assertEqual (len (client .feature_flags ), 1 )
389- self .assertEqual (client .feature_flags [0 ]["key" ], "test-flag" )
390-
391- # Missing cohorts should default to empty dict
392- self .assertEqual (client .cohorts , {})
393-
394- client .join ()
395-
396- @mock .patch ("posthog.client.get" )
397- def test_handles_cache_data_with_none_values (self , mock_get ):
398- """When cache returns data with None values, should use fallback defaults."""
399- self .cache_provider .should_fetch_return_value = False
400- # All values are None - should use 'or []' / 'or {}' fallbacks
401- self .cache_provider .stored_data = {
402- "flags" : None ,
403- "group_type_mapping" : None ,
404- "cohorts" : None ,
405- }
406-
407- client = self ._create_client_with_cache ()
408- client ._load_feature_flags ()
409-
410- # Should not call API
411- mock_get .assert_not_called ()
412-
413- # All fields should have safe defaults
414- self .assertEqual (client .feature_flags , [])
415- self .assertEqual (client .group_type_mapping , {})
416- self .assertEqual (client .cohorts , {})
417-
418- client .join ()
419-
420371
421372class TestShutdownLifecycle (TestFlagDefinitionCacheProvider ):
422373 """Tests for shutdown lifecycle."""
0 commit comments