10000 fix: Forced variation not available in experiment by ozayr-zaviar · Pull Request #367 · optimizely/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

fix: Forced variation not available in experiment #367

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

Merged
merged 8 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit test added for no active experiment in create impression event
  • Loading branch information
ozayr-zaviar committed Dec 14, 2021
commit e480d8d5a37f3a707041ff2975cc8b4a3dab634d
2 changes: 1 addition & 1 deletion optimizely/event/user_event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def create_impression_event(
if not variation and variation_id and experiment_id:
# need this condition when we send events involving forced decisions
variation = project_config.get_variation_from_id_by_experiment_id(experiment_id, variation_id)

event_context = user_event.EventContext(
project_config.account_id, project_config.project_id, project_config.revision, project_config.anonymize_ip,
)
Expand Down
11 changes: 11 additions & 0 deletions tests/test_user_event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ def test_impression_event__with_attributes(self):
[x.__dict__ for x in expected_attrs], [x.__dict__ for x in impression_event.visitor_attributes],
)

def test_impression_event__no_active_experiment(self):
project_config = self.project_config
user_id = 'test_user'

user_attributes = {'test_attribute': 'test_value', 'boolean_key': True}

impression_event = UserEventFactory.create_impression_event(
project_config, None, '111128', 'flag_key', 'rule_key', 'rule_type', True, user_id, user_attributes
)
self.assertIsNone(impression_event)
Copy link
< 6BE3 /details-menu>
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be none. With FD, {None experiment} is a valid case, for which we should forward the impression event.


def test_conversion_event(self):
project_config = self.project_config
user_id = 'test_user'
Expand Down
0