def test_emits_post_disable_event(self): feature_name = self.txt() events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.POST_DISABLE, f=listener) self.client.events = events self.client.create(feature_name) self.client.disable(feature_name) listener.assert_called_once_with(feature_name)
def test_emits_pre_destroy_event(self): feature_name = self.txt() events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.PRE_DESTROY, f=listener) self.client.events = events self.client.create(feature_name) self.client.destroy(feature_name) listener.assert_called_once_with(feature_name)
def test_emits_post_set_bucketer_event(self): feature_name = self.txt() events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.POST_SET_BUCKETER, f=listener) percentage_value = 0.1 bucketer = PercentageBucketer(percentage=Percentage(percentage_value)) self.client.events = events self.store.create(feature_name) self.client.set_bucketer(feature_name, bucketer) listener.assert_called_once_with(feature_name, bucketer)
def test_emits_post_add_condition_event(self): feature_name = self.txt() events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.POST_ADD_CONDITION, f=listener) condition_checks = {self.txt(): True} condition = Condition(**condition_checks) self.client.events = events self.store.create(feature_name) self.client.add_condition(feature_name, condition) listener.assert_called_once_with(feature_name, condition)
def test_emits_post_set_client_data_event(self): feature_name = self.txt() events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.POST_SET_CLIENT_DATA, f=listener) existing_data = {"existing_key": self.txt()} self.client.events = events self.client.create(feature_name, client_data=existing_data) new_data = {"existing_key": self.txt(), "new_key": self.txt()} self.client.set_client_data(feature_name, new_data) listener.assert_called_once_with(feature_name, new_data)
def test_emits_post_create_event_with_correct_args(self): events = FlipperEventEmitter() listener = MagicMock() events.on(EventType.POST_CREATE, f=listener) feature_name = self.txt() client_data = {"x": 10} self.client.events = events self.client.create(feature_name, is_enabled=True, client_data=client_data) listener.assert_called_with(feature_name, is_enabled=True, client_data=client_data)