-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad6a5ee
commit aa83cdb
Showing
5 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class _SDKFlags: | ||
_flags = {} | ||
|
||
@staticmethod | ||
def set_flags(new_flags): | ||
_SDKFlags._flags = new_flags | ||
|
||
@staticmethod | ||
def on(key): | ||
return _SDKFlags._flags.get(key, False) is True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import unittest | ||
|
||
from statsig import _SDKFlags | ||
|
||
|
||
class TestSDKFlags(unittest.TestCase): | ||
|
||
def test_empty(self): | ||
self.assertEqual(_SDKFlags.on("not_a_flag"), False) | ||
|
||
def test_malformed(self): | ||
_SDKFlags.set_flags({"bad_flag": 1}) | ||
self.assertEqual(_SDKFlags.on("bad_flag"), False) | ||
|
||
def test_flag_set(self): | ||
_SDKFlags.set_flags({"a_flag": True}) | ||
self.assertEqual(_SDKFlags.on("a_flag"), True) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |