Exemplo n.º 1
0
class TestPostqueueCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {})

        self.collector = PostqueueCollector(config, {})

    @patch.object(Collector, 'publish_metric')
    def test_should_work_with_emails_in_queue(self, publish_mock):
        with patch.object(
                PostqueueCollector, 'get_postqueue_output',
                Mock(return_value=self.getFixture(
                    'postqueue_emails').getvalue())):
            self.collector.collect()

        self.assertPublishedMetric(publish_mock, 'count', 3)

    @patch.object(Collector, 'publish_metric')
    def test_should_work_with_empty_queue(self, publish_mock):
        with patch.object(
                PostqueueCollector, 'get_postqueue_output',
                Mock(return_value=self.getFixture(
                    'postqueue_empty').getvalue())):
            self.collector.collect()

        self.assertPublishedMetric(publish_mock, 'count', 0)
Exemplo n.º 2
0
class TestPostqueueCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {})

        self.collector = PostqueueCollector(config, {})

    @patch.object(Collector, 'publish')
    def test_should_work_with_emails_in_queue(self, publish_mock):
        with patch.object(
                PostqueueCollector, 'get_postqueue_output',
                Mock(return_value=self.getFixture(
                    'postqueue_emails').getvalue())):
            self.collector.collect()

        metrics = {'count': 3}

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])

        self.assertPublishedMany(publish_mock, metrics)

    @patch.object(Collector, 'publish')
    def test_should_work_with_empty_queue(self, publish_mock):
        with patch.object(
                PostqueueCollector, 'get_postqueue_output',
                Mock(return_value=self.getFixture(
                    'postqueue_empty').getvalue())):
            self.collector.collect()

        metrics = {'count': 0}

        self.assertPublishedMany(publish_mock, metrics)
Exemplo n.º 3
0
class TestPostqueueCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {})

        self.collector = PostqueueCollector(config, {})

    @patch.object(Collector, 'publish_metric')
    def test_should_work_with_emails_in_queue(self, publish_mock):
        with patch.object(PostqueueCollector,
                          'get_postqueue_output',
                          Mock(return_value=self.getFixture(
                              'postqueue_emails').getvalue())):
            self.collector.collect()

        self.assertPublishedMetric(publish_mock, 'count', 3)

    @patch.object(Collector, 'publish_metric')
    def test_should_work_with_empty_queue(self, publish_mock):
        with patch.object(PostqueueCollector,
                          'get_postqueue_output',
                          Mock(return_value=self.getFixture(
                              'postqueue_empty').getvalue())):
            self.collector.collect()

        self.assertPublishedMetric(publish_mock, 'count', 0)
Exemplo n.º 4
0
class TestPostqueueCollector(CollectorTestCase):

    def setUp(self):
        config = get_collector_config('PostqueueCollector', {
        })

        self.collector = PostqueueCollector(config, {})

    def test_import(self):
        self.assertTrue(PostqueueCollector)

    @patch.object(Collector, 'publish')
    def test_should_work_with_emails_in_queue(self, publish_mock):
        patch_collector = patch.object(
            PostqueueCollector,
            'get_postqueue_output',
            Mock(return_value=self.getFixture(
                'postqueue_emails').getvalue()))
        patch_collector.start()
        self.collector.collect()
        patch_collector.stop()

        metrics = {
            'count': 3
        }

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])

        self.assertPublishedMany(publish_mock, metrics)

    @patch.object(Collector, 'publish')
    def test_should_work_with_empty_queue(self, publish_mock):
        patch_collector = patch.object(
            PostqueueCollector,
            'get_postqueue_output',
            Mock(return_value=self.getFixture(
                'postqueue_empty').getvalue()))
        patch_collector.start()
        self.collector.collect()
        patch_collector.stop()

        metrics = {
            'count': 0
        }

        self.assertPublishedMany(publish_mock, metrics)
Exemplo n.º 5
0
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {})

        self.collector = PostqueueCollector(config, {})
Exemplo n.º 6
0
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {
        })

        self.collector = PostqueueCollector(config, {})