@@ -1439,9 +1439,11 @@ def test_compute_inactive_flags_locally(self, patch_flags, patch_capture):
14391439 self .assertEqual (patch_capture .call_count , 0 )
14401440
14411441 @mock .patch ("posthog.client.flags" )
1442- @mock .patch ("posthog.client.get" )
1443- def test_feature_flags_local_evaluation_None_values (self , patch_get , patch_flags ):
1442+ def test_feature_flags_local_evaluation_None_values (self , patch_flags ):
14441443 client = Client (FAKE_TEST_API_KEY , secret_key = FAKE_TEST_API_KEY )
1444+ load_patch = mock .patch .object (client , "_load_feature_flags" )
1445+ patch_load = load_patch .start ()
1446+ self .addCleanup (load_patch .stop )
14451447 client .feature_flags = [
14461448 {
14471449 id : 1 ,
@@ -1498,7 +1500,7 @@ def test_feature_flags_local_evaluation_None_values(self, patch_get, patch_flags
14981500
14991501 self .assertEqual (feature_flag_match , False )
15001502 self .assertEqual (patch_flags .call_count , 0 )
1501- self . assertEqual ( patch_get . call_count , 0 )
1503+ patch_load . assert_not_called ( )
15021504
15031505 feature_flag_match = client .get_feature_flag (
15041506 "beta-feature" ,
@@ -1514,9 +1516,11 @@ def test_feature_flags_local_evaluation_None_values(self, patch_get, patch_flags
15141516 self .assertEqual (feature_flag_match , True )
15151517
15161518 @mock .patch ("posthog.client.flags" )
1517- @mock .patch ("posthog.client.get" )
1518- def test_feature_flags_local_evaluation_for_cohorts (self , patch_get , patch_flags ):
1519+ def test_feature_flags_local_evaluation_for_cohorts (self , patch_flags ):
15191520 client = Client (FAKE_TEST_API_KEY , secret_key = FAKE_TEST_API_KEY )
1521+ load_patch = mock .patch .object (client , "_load_feature_flags" )
1522+ patch_load = load_patch .start ()
1523+ self .addCleanup (load_patch .stop )
15201524 client .feature_flags = [
15211525 {
15221526 "id" : 2 ,
@@ -1578,7 +1582,7 @@ def test_feature_flags_local_evaluation_for_cohorts(self, patch_get, patch_flags
15781582
15791583 self .assertEqual (feature_flag_match , False )
15801584 self .assertEqual (patch_flags .call_count , 0 )
1581- self . assertEqual ( patch_get . call_count , 0 )
1585+ patch_load . assert_not_called ( )
15821586
15831587 feature_flag_match = client .get_feature_flag (
15841588 "beta-feature" ,
@@ -1588,7 +1592,7 @@ def test_feature_flags_local_evaluation_for_cohorts(self, patch_get, patch_flags
15881592 # even though 'other' property is not present, the cohort should still match since it's an OR condition
15891593 self .assertEqual (feature_flag_match , True )
15901594 self .assertEqual (patch_flags .call_count , 0 )
1591- self . assertEqual ( patch_get . call_count , 0 )
1595+ patch_load . assert_not_called ( )
15921596
15931597 feature_flag_match = client .get_feature_flag (
15941598 "beta-feature" ,
@@ -1597,14 +1601,14 @@ def test_feature_flags_local_evaluation_for_cohorts(self, patch_get, patch_flags
15971601 )
15981602 self .assertEqual (feature_flag_match , True )
15991603 self .assertEqual (patch_flags .call_count , 0 )
1600- self . assertEqual ( patch_get . call_count , 0 )
1604+ patch_load . assert_not_called ( )
16011605
16021606 @mock .patch ("posthog.client.flags" )
1603- @mock .patch ("posthog.client.get" )
1604- def test_feature_flags_local_evaluation_for_negated_cohorts (
1605- self , patch_get , patch_flags
1606- ):
1607+ def test_feature_flags_local_evaluation_for_negated_cohorts (self , patch_flags ):
16071608 client = Client (FAKE_TEST_API_KEY , secret_key = FAKE_TEST_API_KEY )
1609+ load_patch = mock .patch .object (client , "_load_feature_flags" )
1610+ patch_load = load_patch .start ()
1611+ self .addCleanup (load_patch .stop )
16081612 client .feature_flags = [
16091613 {
16101614 "id" : 2 ,
@@ -1667,7 +1671,7 @@ def test_feature_flags_local_evaluation_for_negated_cohorts(
16671671
16681672 self .assertEqual (feature_flag_match , False )
16691673 self .assertEqual (patch_flags .call_count , 0 )
1670- self . assertEqual ( patch_get . call_count , 0 )
1674+ patch_load . assert_not_called ( )
16711675
16721676 feature_flag_match = client .get_feature_flag (
16731677 "beta-feature" ,
@@ -1677,7 +1681,7 @@ def test_feature_flags_local_evaluation_for_negated_cohorts(
16771681 # even though 'other' property is not present, the cohort should still match since it's an OR condition
16781682 self .assertEqual (feature_flag_match , True )
16791683 self .assertEqual (patch_flags .call_count , 0 )
1680- self . assertEqual ( patch_get . call_count , 0 )
1684+ patch_load . assert_not_called ( )
16811685
16821686 feature_flag_match = client .get_feature_flag (
16831687 "beta-feature" ,
@@ -1686,7 +1690,7 @@ def test_feature_flags_local_evaluation_for_negated_cohorts(
16861690 )
16871691 # since 'other' is negated, we return False. Since 'nation' is not present, we can't tell whether the flag should be true or false, so fall back to /flags
16881692 self .assertEqual (patch_flags .call_count , 1 )
1689- self . assertEqual ( patch_get . call_count , 0 )
1693+ patch_load . assert_not_called ( )
16901694
16911695 patch_flags .reset_mock ()
16921696
@@ -1697,17 +1701,17 @@ def test_feature_flags_local_evaluation_for_negated_cohorts(
16971701 )
16981702 self .assertEqual (feature_flag_match , True )
16991703 self .assertEqual (patch_flags .call_count , 0 )
1700- self . assertEqual ( patch_get . call_count , 0 )
1704+ patch_load . assert_not_called ( )
17011705
17021706 @mock .patch ("posthog.feature_flags.log" )
17031707 @mock .patch ("posthog.client.flags" )
1704- @mock .patch ("posthog.client.get" )
1705- def test_feature_flags_with_flag_dependencies (
1706- self , patch_get , patch_flags , mock_log
1707- ):
1708+ def test_feature_flags_with_flag_dependencies (self , patch_flags , mock_log ):
17081709 # Mock remote flags call to return empty for this flag (fallback returns None)
17091710 patch_flags .return_value = {"featureFlags" : {}}
17101711 client = Client (FAKE_TEST_API_KEY , secret_key = FAKE_TEST_API_KEY )
1712+ load_patch = mock .patch .object (client , "_load_feature_flags" )
1713+ patch_load = load_patch .start ()
1714+ self .addCleanup (load_patch .stop )
17111715 client .feature_flags = [
17121716 {
17131717 "id" : 1 ,
@@ -1750,7 +1754,7 @@ def test_feature_flags_with_flag_dependencies(
17501754 )
17511755 self .assertIsNone (feature_flag_match )
17521756 self .assertEqual (patch_flags .call_count , 1 )
1753- self . assertEqual ( patch_get . call_count , 0 )
1757+ patch_load . assert_not_called ( )
17541758
17551759 # Test with email that doesn't match (should also fall back to remote due to missing dependency)
17561760 feature_flag_match = client .get_feature_flag (
@@ -1760,7 +1764,7 @@ def test_feature_flags_with_flag_dependencies(
17601764 )
17611765 self .assertIsNone (feature_flag_match )
17621766 self .assertEqual (patch_flags .call_count , 2 ) # Called twice now
1763- self . assertEqual ( patch_get . call_count , 0 )
1767+ patch_load . assert_not_called ( )
17641768
17651769 @mock .patch ("posthog.client.flags" )
17661770 @mock .patch ("posthog.client.get" )
0 commit comments