コード例 #1
0
    def test_run_unsubscribe_only_topics(self, client, kafka_unsubscriber):
        with mock.patch.object(
            UnsubscribeTopics,
            'preprocess_args',
            spec=UnsubscribeTopics.preprocess_args,
            return_value=self.topics_partitions,
        ):
            args = mock.Mock(topics=["topic1", "topic3"], topic=None, partitions=None)

            UnsubscribeTopics.run(args, self.cluster_config)
コード例 #2
0
    def test_run_unsubscribe_only_topics(self, client, zk, zk_unsubscriber, kafka_unsubscriber):
        with mock.patch.object(
                UnsubscribeTopics,
                'preprocess_args',
                spec=UnsubscribeTopics.preprocess_args,
                return_value=self.topics_partitions,
        ):
            args = mock.Mock(topics=["topic1", "topic3"], topic=None, partitions=None)

            UnsubscribeTopics.run(args, self.cluster_config)
コード例 #3
0
    def test_run_unsuscribe_missing_topics(self, client, zk, zk_unsubscriber, kafka_unsubscriber):
        with mock.patch.object(
                UnsubscribeTopics,
                'preprocess_args',
                spec=UnsubscribeTopics.preprocess_args,
                return_value=self.topics_partitions,
        ):
            args = mock.Mock(topics=["topic2", "baz"], topic=None, partitions=None)

            with pytest.raises(SystemExit):
                UnsubscribeTopics.run(args, self.cluster_config)
コード例 #4
0
    def test_run_unsubscribe_kafka(self, client, kafka_unsubscriber):
        with mock.patch.object(
            UnsubscribeTopics,
            'preprocess_args',
            spec=UnsubscribeTopics.preprocess_args,
            return_value=self.topics_partitions,
        ):
            args = mock.Mock(topic=None, topics=None)

            UnsubscribeTopics.run(args, self.cluster_config)

            kafka_obj = kafka_unsubscriber.return_value

            assert kafka_obj.unsubscribe_topics.call_count == 1
コード例 #5
0
    def test_run_unsubscribe_kafka(self, client, kafka_unsubscriber):
        with mock.patch.object(
                UnsubscribeTopics,
                'preprocess_args',
                spec=UnsubscribeTopics.preprocess_args,
                return_value=self.topics_partitions,
        ):
            args = mock.Mock(topic=None, topics=None)

            UnsubscribeTopics.run(args, self.cluster_config)

            kafka_obj = kafka_unsubscriber.return_value

            assert kafka_obj.unsubscribe_topics.call_count == 1
コード例 #6
0
    def test_run_unsubscribe_kafka(self, client, zk, zk_unsubscriber, kafka_unsubscriber):
        with mock.patch.object(
                UnsubscribeTopics,
                'preprocess_args',
                spec=UnsubscribeTopics.preprocess_args,
                return_value=self.topics_partitions,
        ):
            args = mock.Mock(storage='kafka')

            UnsubscribeTopics.run(args, self.cluster_config)

            zk_obj = zk_unsubscriber.return_value
            kafka_obj = kafka_unsubscriber.return_value

            assert zk_obj.unsubscribe_topic.call_count == 0
            assert kafka_obj.unsubscribe_topic.call_count == 1
コード例 #7
0
    def test_run_unsubscribe_kafka(self, client, zk, zk_unsubscriber, kafka_unsubscriber):
        with mock.patch.object(
                UnsubscribeTopics,
                'preprocess_args',
                spec=UnsubscribeTopics.preprocess_args,
                return_value=self.topics_partitions,
        ):
            args = mock.Mock(storage='kafka')

            UnsubscribeTopics.run(args, self.cluster_config)

            zk_obj = zk_unsubscriber.return_value
            kafka_obj = kafka_unsubscriber.return_value

            assert zk_obj.unsubscribe_topic.call_count == 0
            assert kafka_obj.unsubscribe_topic.call_count == 1