Skip to content

Commit 16acf2e

Browse files
committed
better testing and org
1 parent df9ae05 commit 16acf2e

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

posthog/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ def feature_enabled(self, key, distinct_id, default=False):
280280
"distinct_id": distinct_id,
281281
"personal_api_key": self.personal_api_key,
282282
}
283-
request = decide(self.api_key, self.host, timeout=10, **request_data)
284-
resp_data = request.json()
283+
resp_data = decide(self.api_key, self.host, timeout=10, **request_data)
285284
response = key in resp_data['featureFlags']
286285
except Exception as e:
287286
response = default

posthog/request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def decide(api_key, host=None, gzip=False, timeout=15, **kwargs):
5252
res = post(api_key, host, '/decide/', gzip, timeout, **kwargs)
5353
if res.status_code == 200:
5454
log.debug('Feature flags decided successfully')
55-
return res
55+
return res.json()
5656
try:
5757
payload = res.json()
5858
log.debug('received response: %s', payload)

posthog/test/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def test_feature_enabled_simple(self, patch_get):
259259
}]
260260
self.assertTrue(client.feature_enabled('beta-feature', 'distinct_id'))
261261

262-
@mock.patch('posthog.client.get')
262+
@mock.patch('posthog.client.decide')
263263
def test_feature_enabled_request(self, patch_get):
264264
patch_get.return_value = {
265265
'featureFlags': ['beta-feature']
@@ -269,7 +269,7 @@ def test_feature_enabled_request(self, patch_get):
269269
'id': 1,
270270
'name': 'Beta Feature',
271271
'key': 'beta-feature',
272-
'is_simple_flag': True,
272+
'is_simple_flag': False,
273273
'rollout_percentage': 100
274274
}]
275275
self.assertTrue(client.feature_enabled('beta-feature', 'distinct_id'))

0 commit comments

Comments
 (0)