コード例 #1
0
ファイル: testpostqueue.py プロジェクト: richardc/Diamond
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)
コード例 #2
0
ファイル: testpostqueue.py プロジェクト: songza/Diamond
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)
コード例 #3
0
ファイル: testpostqueue.py プロジェクト: adreyer/Diamond
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)
コード例 #4
0
ファイル: testpostqueue.py プロジェクト: Affirm/Diamond
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)
コード例 #5
0
ファイル: testpostqueue.py プロジェクト: richardc/Diamond
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {})

        self.collector = PostqueueCollector(config, {})
コード例 #6
0
ファイル: testpostqueue.py プロジェクト: 1and1/Diamond
    def setUp(self):
        config = get_collector_config('PostqueueCollector', {
        })

        self.collector = PostqueueCollector(config, {})