def process_arguments(cls, cmd_args): if len(cmd_args) < 3: raise ArgumentError("OffsetCommitV0 requires at least 3 arguments") values = {'group_id': cmd_args.pop(0), 'topics': []} while len(cmd_args) > 0: topic, cmd_args = _parse_next_topic(cmd_args) values['topics'].append(topic) return values
def test_parse_next_topic_remainder(self): val, rest = _parse_next_topic(['topicname', '4,2', 'nexttopic', '9,3']) assert val == { 'topic': 'topicname', 'partitions': [{ 'partition': 4, 'offset': 2, 'metadata': None }] } assert rest == ['nexttopic', '9,3']
def test_parse_next_topic_multiple(self): val, rest = _parse_next_topic(['topicname', '4,2', '9,3']) assert val == { 'topic': 'topicname', 'partitions': [{ 'partition': 4, 'offset': 2, 'metadata': None }, { 'partition': 9, 'offset': 3, 'metadata': None }] } assert rest == []
def test_parse_next_topic_remainder(self): val, rest = _parse_next_topic(['topicname', '4,2', 'nexttopic', '9,3']) assert val == {'topic': 'topicname', 'partitions': [{'partition': 4, 'offset': 2, 'metadata': None}]} assert rest == ['nexttopic', '9,3']
def test_parse_next_topic_multiple(self): val, rest = _parse_next_topic(['topicname', '4,2', '9,3']) assert val == {'topic': 'topicname', 'partitions': [{'partition': 4, 'offset': 2, 'metadata': None}, {'partition': 9, 'offset': 3, 'metadata': None}]} assert rest == []