Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add test for failure case in flags #21796

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions posthog/test/test_feature_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading