Пример #1
0
 def test_preprocess_args_wrong_topic(self, mock_kafka_client):
     args = mock.Mock(groupid="some_group",
                      topic="topic34",
                      partitions=None)
     with self.mock_get_topics() as mock_get_topics, mock.patch.object(
             sys,
             "exit",
             autospec=True,
     ) as mock_exit:
         OffsetManagerBase.preprocess_args(args.groupid,
                                           args.topic, args.partitions,
                                           mock.Mock(), mock_kafka_client)
         assert mock_get_topics.called
         assert mock_exit.called
Пример #2
0
 def test_preprocess_args_with_topics_no_partitions(self,
                                                    mock_kafka_client):
     args = mock.Mock(groupid="some_group", topic="topic1", partitions=None)
     expected_topics_dict = {"topic1": [0, 1, 2]}
     with self.mock_get_topics() as mock_get_topics:
         topics_dict = OffsetManagerBase.preprocess_args(
             args.groupid, args.topic, args.partitions, mock.Mock(),
             mock_kafka_client)
         assert mock_get_topics.called
         assert topics_dict == expected_topics_dict
Пример #3
0
    def test_preprocess_args_partitions_without_topic(self, mock_kafka_client):
        args = mock.Mock(
            groupid="some_group",
            topic=None,
            partitions=[0, 1, 2]
        )

        with self.mock_get_topics(), mock.patch.object(
            sys,
            "exit",
            autospec=True,
        ) as mock_exit:
            OffsetManagerBase.preprocess_args(
                args.groupid,
                args.topic,
                args.partitions,
                mock.Mock(),
                mock_kafka_client
            )
            assert mock_exit.called
Пример #4
0
    def test_preprocess_args_topics_and_partitions(self, mock_kafka_client):
        args = mock.Mock(
            groupid="some_group",
            partitions=[0, 1, 2],
            topics=["topic1", "topic2"],
        )

        with self.mock_get_topics(), mock.patch.object(
            sys,
            "exit",
            autospec=True,
        ) as mock_exit:
            OffsetManagerBase.preprocess_args(
                args.groupid,
                args.topic,
                args.partitions,
                mock.Mock(),
                mock_kafka_client,
                topics=args.topics,
            )
            assert mock_exit.called
Пример #5
0
    def test_preprocess_args_topics_and_partitions(self, mock_kafka_client):
        args = mock.Mock(
            groupid="some_group",
            partitions=[0, 1, 2],
            topics=["topic1", "topic2"],
        )

        with self.mock_get_topics(), mock.patch.object(
                sys,
                "exit",
                autospec=True,
        ) as mock_exit:
            OffsetManagerBase.preprocess_args(
                args.groupid,
                args.topic,
                args.partitions,
                mock.Mock(),
                mock_kafka_client,
                topics=args.topics,
            )
            assert mock_exit.called
Пример #6
0
 def test_preprocess_args_with_topics_no_partitions(self, mock_kafka_client):
     args = mock.Mock(
         groupid="some_group",
         topic="topic1",
         partitions=None
     )
     expected_topics_dict = {"topic1": [0, 1, 2]}
     with self.mock_get_topics() as mock_get_topics:
         topics_dict = OffsetManagerBase.preprocess_args(
             args.groupid,
             args.topic,
             args.partitions,
             mock.Mock(),
             mock_kafka_client
         )
         assert mock_get_topics.called
         assert topics_dict == expected_topics_dict
Пример #7
0
    def test_preprocess_args_topics(self, mock_kafka_client):
        args = mock.Mock(
            topic=None,
            partitions=None,
            groupid="some_group",
            topics=["topic1", "topic2"],
        )

        expected_topics_dict = {"topic1": [0, 1, 2], "topic2": [0, 1, 2, 3]}

        with self.mock_get_topics() as mock_get_topics:
            topics_dict = OffsetManagerBase.preprocess_args(
                args.groupid,
                args.topic,
                args.partitions,
                mock.Mock(),
                mock_kafka_client,
                topics=args.topics,
            )
            assert mock_get_topics.called
            assert topics_dict == expected_topics_dict
Пример #8
0
    def test_preprocess_args_topics(self, mock_kafka_client):
        args = mock.Mock(
            topic=None,
            partitions=None,
            groupid="some_group",
            topics=["topic1", "topic2"],
        )

        expected_topics_dict = {"topic1": [0, 1, 2], "topic2": [0, 1, 2, 3]}

        with self.mock_get_topics() as mock_get_topics:
            topics_dict = OffsetManagerBase.preprocess_args(
                args.groupid,
                args.topic,
                args.partitions,
                mock.Mock(),
                mock_kafka_client,
                topics=args.topics,
            )
            assert mock_get_topics.called
            assert topics_dict == expected_topics_dict