Skip to content

Commit 8c0211e

Browse files
committed
Add failing unit test
Test highlights a bug in our current comparison logic
1 parent 994003f commit 8c0211e

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

posthog/test/test_feature_flags.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def setUp(self):
3232
self.client = Client(FAKE_TEST_API_KEY, on_error=self.set_fail)
3333

3434
@mock.patch("posthog.client.get")
35-
def test_flag_person_properties(self, patch_get):
35+
def test_flag_person_properties(self):
3636
self.client.feature_flags = [
3737
{
3838
"id": 1,
@@ -69,6 +69,59 @@ def test_flag_person_properties(self, patch_get):
6969
self.assertTrue(feature_flag_match)
7070
self.assertFalse(not_feature_flag_match)
7171

72+
def test_case_insensitive_matching(self):
73+
self.client.feature_flags = [
74+
{
75+
"id": 1,
76+
"name": "Beta Feature",
77+
"key": "person-flag",
78+
"is_simple_flag": True,
79+
"active": True,
80+
"filters": {
81+
"groups": [
82+
{
83+
"properties": [
84+
{
85+
"key": "location",
86+
"operator": "exact",
87+
"value": ["Straße"],
88+
"type": "person",
89+
}
90+
],
91+
"rollout_percentage": 100,
92+
},
93+
{
94+
"properties": [
95+
{
96+
"key": "star",
97+
"operator": "exact",
98+
"value": ["ſun"],
99+
"type": "person",
100+
}
101+
],
102+
"rollout_percentage": 100,
103+
},
104+
],
105+
},
106+
}
107+
]
108+
109+
self.assertTrue(
110+
self.client.get_feature_flag("person-flag", "some-distinct-id", person_properties={"location": "straße"})
111+
)
112+
113+
self.assertTrue(
114+
self.client.get_feature_flag("person-flag", "some-distinct-id", person_properties={"location": "strasse"})
115+
)
116+
117+
self.assertTrue(
118+
self.client.get_feature_flag("person-flag", "some-distinct-id", person_properties={"star": "ſun"})
119+
)
120+
121+
self.assertTrue(
122+
self.client.get_feature_flag("person-flag", "some-distinct-id", person_properties={"star": "sun"})
123+
)
124+
72125
@mock.patch("posthog.client.decide")
73126
@mock.patch("posthog.client.get")
74127
def test_flag_group_properties(self, patch_get, patch_decide):

0 commit comments

Comments
 (0)