def setUp(self): self._split_parser = SplitParser(object()) matcher = { 'matcherType': 'PART_OF_SET', 'whitelistMatcherData': {'whitelist': ['ABC', 'DEF', 'GHI']} } split = {'conditions': [{'matcher': matcher}]} self._matcher = (self._split_parser._parse_matcher(split, matcher) ._matcher.delegate)
def setUp(self): self._split_parser = SplitParser(object()) matcher = { 'matcherType': 'EQUAL_TO_BOOLEAN', 'booleanMatcherData': True } split = {'conditions': [{'matcher': matcher}]} self._matcher = (self._split_parser._parse_matcher(split, matcher) ._matcher.delegate)
def setUp(self): self._split_parser = SplitParser(object()) matcher = { 'matcherType': 'MATCHES_STRING', 'stringMatcherData': '[a-z]' } split = {'conditions': [{'matcher': matcher}]} self._matcher = (self._split_parser._parse_matcher(split, matcher) ._matcher.delegate)
def setUp(self): self._split_parser = SplitParser(object()) matcher = { 'matcherType': 'IN_SPLIT_TREATMENT', 'dependencyMatcherData': { 'split': 'someSplit', 'treatments': ['on'] } } split = {'conditions': [{'matcher': matcher}]} self._matcher = (self._split_parser._parse_matcher(split, matcher) ._matcher.delegate) self._mock = self.patch('splitio.clients.MatcherClient')
def _build_split_fetcher(self): """ Build the json backed split fetcher :return: The json backed split fetcher :rtype: JSONFileSplitFetcher """ segment_fetcher = JSONFileSegmentFetcher(self._segment_changes_file_name) split_parser = SplitParser(segment_fetcher) split_fetcher = JSONFileSplitFetcher( self._split_changes_file_name, split_parser ) return split_fetcher
def _build_split_fetcher(self): """ Build the self refreshing split fetcher :return: The self refreshing split fetcher :rtype: SelfRefreshingSplitFetcher """ segment_change_fetcher = ApiSegmentChangeFetcher(self._sdk_api) segment_fetcher = SelfRefreshingSegmentFetcher( segment_change_fetcher, interval=self._segment_fetcher_interval ) split_change_fetcher = ApiSplitChangeFetcher(self._sdk_api) split_parser = SplitParser(segment_fetcher) split_fetcher = SelfRefreshingSplitFetcher( split_change_fetcher, split_parser, interval=self._split_fetcher_interval ) return split_fetcher
def setUp(self): self.some_partial_split = mock.MagicMock() self.some_segment_fetcher = mock.MagicMock() self.combining_matcher_mock = self.patch( 'splitio.splits.CombiningMatcher') self.parser = SplitParser(self.some_segment_fetcher) self.parse_matcher_mock = self.patch_object(self.parser, '_parse_matcher') self.parse_matcher_side_effect = [mock.MagicMock() for _ in range(2)] self.parse_matcher_mock.side_effect = self.parse_matcher_side_effect self.parse_combiner_mock = self.patch_object(self.parser, '_parse_combiner') self.some_matchers = [mock.MagicMock(), mock.MagicMock()] self.some_matcher_group = { 'matchers': self.some_matchers, 'combiner': mock.MagicMock() }
def setUp(self): self.some_partial_split = mock.MagicMock() self.some_segment_fetcher = mock.MagicMock() self.some_matcher = mock.MagicMock() self.parser = SplitParser(self.some_segment_fetcher) self.get_matcher_data_data_type_mock = self.patch_object( self.parser, '_get_matcher_data_data_type') self.equal_to_matcher_mock = self.patch( 'splitio.splits.EqualToMatcher') self.greater_than_or_equal_to_matcher_mock = self.patch( 'splitio.splits.GreaterThanOrEqualToMatcher') self.less_than_or_equal_to_matcher_mock = self.patch( 'splitio.splits.LessThanOrEqualToMatcher') self.between_matcher_mock = self.patch('splitio.splits.BetweenMatcher') self.some_in_segment_matcher = { 'matcherType': 'IN_SEGMENT', 'userDefinedSegmentMatcherData': { 'segmentName': mock.MagicMock() } } self.some_whitelist_matcher = { 'matcherType': 'WHITELIST', 'whitelistMatcherData': { 'whitelist': mock.MagicMock() } } self.some_equal_to_matcher = self._get_unary_number_matcher('EQUAL_TO') self.some_greater_than_or_equal_to_matcher = self._get_unary_number_matcher( 'GREATER_THAN_OR_EQUAL_TO') self.some_less_than_or_equal_to_matcher = self._get_unary_number_matcher( 'LESS_THAN_OR_EQUAL_TO') self.some_between_matcher = { 'matcherType': 'BETWEEN', 'betweenMatcherData': { 'start': mock.MagicMock(), 'end': mock.MagicMock(), } }
def setUp(self): self.some_partial_split = mock.MagicMock() self.some_segment_fetcher = mock.MagicMock() self.some_matcher = mock.MagicMock() self.parser = SplitParser(self.some_segment_fetcher) self.parse_matcher_all_keys_mock = self.patch_object( self.parser, '_parse_matcher_all_keys') self.parse_matcher_in_segment_mock = self.patch_object( self.parser, '_parse_matcher_in_segment') self.parse_matcher_whitelist_mock = self.patch_object( self.parser, '_parse_matcher_whitelist') self.parse_matcher_equal_to_mock = self.patch_object( self.parser, '_parse_matcher_equal_to') self.parse_matcher_greater_than_or_equal_to_mock = self.patch_object( self.parser, '_parse_matcher_greater_than_or_equal_to') self.parse_matcher_less_than_or_equal_to_mock = self.patch_object( self.parser, '_parse_matcher_less_than_or_equal_to') self.parse_matcher_between_mock = self.patch_object( self.parser, '_parse_matcher_between') self.parser._parse_matcher_fake = mock.MagicMock()
def setUp(self): self.some_segment_fetcher = mock.MagicMock() self.parser = SplitParser(self.some_segment_fetcher)
def setUp(self): self.some_split = mock.MagicMock() self.some_segment_fetcher = mock.MagicMock() self.some_block_until_ready = mock.MagicMock() self.partition_mock = self.patch('splitio.splits.Partition') self.partition_mock_side_effect = [mock.MagicMock() for _ in range(3)] self.partition_mock.side_effect = self.partition_mock_side_effect self.condition_mock = self.patch('splitio.splits.Condition') self.condition_mock_side_effect = [mock.MagicMock() for _ in range(2)] self.condition_mock.side_effect = self.condition_mock_side_effect self.parser = SplitParser(self.some_segment_fetcher) self.parse_split_mock = self.patch_object(self.parser, '_parse_split') self.parse_matcher_group_mock = self.patch_object( self.parser, '_parse_matcher_group') self.parse_matcher_group_mock_side_effect = [ mock.MagicMock() for _ in range(2) ] self.parse_matcher_group_mock.side_effect = self.parse_matcher_group_mock_side_effect self.partition_0 = { 'treatment': mock.MagicMock(), 'size': mock.MagicMock() } self.partition_1 = { 'treatment': mock.MagicMock(), 'size': mock.MagicMock() } self.partition_2 = { 'treatment': mock.MagicMock(), 'size': mock.MagicMock() } self.matcher_group_0 = mock.MagicMock() self.matcher_group_1 = mock.MagicMock() self.label_0 = mock.MagicMock() self.label_1 = mock.MagicMock() self.some_split = { 'status': 'ACTIVE', 'name': mock.MagicMock(), 'seed': mock.MagicMock(), 'killed': mock.MagicMock(), 'defaultTreatment': mock.MagicMock(), 'conditions': [{ 'matcherGroup': self.matcher_group_0, 'partitions': [self.partition_0], 'label': self.label_0 }, { 'matcherGroup': self.matcher_group_1, 'partitions': [self.partition_1, self.partition_2], 'label': self.label_1 }] }
def setUp(self): self.some_split = mock.MagicMock() self.some_segment_fetcher = mock.MagicMock() self.parser = SplitParser(self.some_segment_fetcher) self.internal_parse_mock = self.patch_object(self.parser, '_parse')