-
Notifications
You must be signed in to change notification settings - Fork 36
feat: add user context #305
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
Conversation
tests/test_user_context.py
Outdated
@@ -0,0 +1,34 @@ | |||
# Copyright 2019, Optimizely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2020
optimizely/user_context.py
Outdated
@@ -0,0 +1,84 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Omit this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Should add mutex control for attributes. More tests suggested.
Returns: | ||
None | ||
""" | ||
self.user_attributes[attribute_key] = attribute_value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a mutex control for attributes read/write?
"setAttributes" and attribute -reading for decide can happen in other threads. See C#-sdk as a good reference (optimizely/csharp-sdk#253)
uc.set_attribute("key", "value") | ||
self.assertEqual(uc.user_attributes["key"], "value", "should have added attribute") | ||
uc.set_attribute("key", "value2") | ||
self.assertEqual(uc.user_attributes["key"], "value2", "should have new attribute") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have more tests:
- construct with non-empty attributes
- setAttribute can override the init attributes
- attributes not changed once constructed when the caller copy is updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 314
Merged with #309 |
Summary
Test plan
Unit tests added