Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jkw-statsig committed Apr 21, 2022
1 parent 0ba0d08 commit 62ced42
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion statsig/statsig_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StatsigUser:

def __post_init__(self):
# ensure there is a user id or at least a custom ID, empty dict evaluates to false in python so we can use "not" operator to check
if (self.user_id is None or self.user_id == "") and not self.custom_ids:
if (self.user_id is None or self.user_id == "") and (self.custom_ids is None or not self.custom_ids):
raise ValueError(
'user_id or at least a custom ID is required: learn more https://docs.statsig.com/messages/serverRequiredUserID')

Expand Down
4 changes: 1 addition & 3 deletions tests/test_bad_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,17 @@ def test_bad_key(self):
def test_no_user_id(self):
with self.assertRaises(ValueError) as context:
StatsigUser("")

self.assertTrue('user_id' in str(context.exception))

with self.assertRaises(ValueError) as context:
StatsigUser(None)

self.assertTrue('user_id' in str(context.exception))

with self.assertRaises(ValueError) as context:
StatsigUser(None, custom_ids=dict())

self.assertTrue('user_id' in str(context.exception))

u = StatsigUser(None, custom_ids=dict())
user = StatsigUser(None, custom_ids=dict(stableID='123'))
self.assertFalse(user.user_id)
self.assertTrue(user.custom_ids)
Expand Down

0 comments on commit 62ced42

Please sign in to comment.