From 7c2ad60b9421fffaa89366c73dc3dc8f9bd2109b Mon Sep 17 00:00:00 2001 From: Neil Kakkar Date: Wed, 24 Apr 2024 11:27:52 +0100 Subject: [PATCH] chore: Add test for failure case in flags --- posthog/test/test_feature_flag.py | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/posthog/test/test_feature_flag.py b/posthog/test/test_feature_flag.py index 38afbe7dbbcd7..5b979d1ee5bb0 100644 --- a/posthog/test/test_feature_flag.py +++ b/posthog/test/test_feature_flag.py @@ -4681,6 +4681,41 @@ def create_groups(self): def create_feature_flag(self, key="beta-feature", **kwargs): return FeatureFlag.objects.create(team=self.team, name="Beta feature", key=key, created_by=self.user, **kwargs) + @pytest.mark.skip("This case doesn't work yet, which is a bit problematic") + @snapshot_postgres_queries + def test_property_with_double_underscores(self): + Person.objects.create( + team=self.team, + distinct_ids=["307"], + properties={"org__member_count": 15}, + ) + # double scores in key name are interpreted in the ORM as a nested property. + # Unclear if there's a way to solve this, other than moving away from the ORM. + # But, we're doing that anyway with the rust rewrite, so not fixing for now. + + feature_flag1 = self.create_feature_flag( + key="random1", + filters={ + "groups": [ + { + "properties": [ + { + "key": "org__member_count", + "value": "9", + "operator": "gt", + "type": "person", + }, + ] + } + ] + }, + ) + + self.assertEqual( + self.match_flag(feature_flag1, "307"), + FeatureFlagMatch(True, None, FeatureFlagMatchReason.CONDITION_MATCH, 0), + ) + def test_numeric_operator(self): Person.objects.create( team=self.team,