コード例 #1
0
    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10,
            'bin': 'true'
        })

        self.collector = EximCollector(config, None)
コード例 #2
0
ファイル: testexim.py プロジェクト: microsigns/Diamond
    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10,
            'bin': 'true'
        })

        self.collector = EximCollector(config, None)
コード例 #3
0
ファイル: testexim.py プロジェクト: MechanisM/Diamond
    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10
        })

        self.collector = EximCollector(config, None)
        self.collector.COMMAND[0] = 'true'
コード例 #4
0
ファイル: testexim.py プロジェクト: philipcristiano/Diamond
class TestEximCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config("EximCollector", {"interval": 10, "bin": "true"})

        self.collector = EximCollector(config, None)

    @patch("os.access", Mock(return_value=True))
    @patch.object(Collector, "publish")
    def test_should_work_with_synthetic_data(self, publish_mock):
        with patch("subprocess.Popen.communicate", Mock(return_value=("33", ""))):
            self.collector.collect()

        self.assertPublishedMany(publish_mock, {"queuesize": 33.0})

    @patch("os.access", Mock(return_value=True))
    @patch.object(Collector, "publish")
    def test_should_fail_gracefully(self, publish_mock):
        with patch("subprocess.Popen.communicate", Mock(return_value=("", ""))):
            self.collector.collect()

        self.assertPublishedMany(publish_mock, {})

    @patch("os.access", Mock(return_value=False))
    @patch.object(Collector, "publish")
    def test_should_fail_gracefully_2(self, publish_mock):
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})
コード例 #5
0
class TestEximCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10,
            'bin': 'true'
        })

        self.collector = EximCollector(config, None)

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_work_with_synthetic_data(self, publish_mock):
        with patch('subprocess.Popen.communicate',
                   Mock(return_value=('33', ''))):
            self.collector.collect()

        metrics = {'queuesize': 33.0}

        self.setDocExample(self.collector.__class__.__name__, metrics)
        self.assertPublishedMany(publish_mock, metrics)

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully(self, publish_mock):
        with patch('subprocess.Popen.communicate',
                   Mock(return_value=('', ''))):
            self.collector.collect()

        self.assertPublishedMany(publish_mock, {})

    @patch('os.access', Mock(return_value=False))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully_2(self, publish_mock):
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})
コード例 #6
0
ファイル: testexim.py プロジェクト: Affirm/Diamond
class TestEximCollector(CollectorTestCase):

    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10,
            'bin': 'true'
        })

        self.collector = EximCollector(config, None)

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

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_work_with_synthetic_data(self, publish_mock):
        patch_communicate = patch('subprocess.Popen.communicate',
                                  Mock(return_value=('33', '')))

        patch_communicate.start()
        self.collector.collect()
        patch_communicate.stop()

        metrics = {
            'queuesize': 33.0
        }

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

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully(self, publish_mock):
        patch_communicate = patch('subprocess.Popen.communicate',
                                  Mock(return_value=('', '')))

        patch_communicate.start()
        self.collector.collect()
        patch_communicate.stop()

        self.assertPublishedMany(publish_mock, {})

    @patch('os.access', Mock(return_value=False))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully_2(self, publish_mock):
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})
コード例 #7
0
ファイル: testexim.py プロジェクト: MechanisM/Diamond
class TestEximCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('EximCollector', {
            'interval': 10
        })

        self.collector = EximCollector(config, None)
        self.collector.COMMAND[0] = 'true'

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_work_with_synthetic_data(self, publish_mock):
        with patch('subprocess.Popen.communicate', Mock(return_value =
            ( '33' , '')
        )):
            self.collector.collect()
            
        self.assertPublishedMany(publish_mock, {
            'queuesize' : 33.0
        })

    @patch('os.access', Mock(return_value=True))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully(self, publish_mock):
        with patch('subprocess.Popen.communicate', Mock(return_value =
            ( '' , '')
        )):
            self.collector.collect()

        self.assertPublishedMany(publish_mock, {})

    @patch('os.access', Mock(return_value=False))
    @patch.object(Collector, 'publish')
    def test_should_fail_gracefully_2(self, publish_mock):
        self.collector.collect()
        self.assertPublishedMany(publish_mock, {})
コード例 #8
0
ファイル: testexim.py プロジェクト: philipcristiano/Diamond
    def setUp(self):
        config = get_collector_config("EximCollector", {"interval": 10, "bin": "true"})

        self.collector = EximCollector(config, None)
コード例 #9
0
ファイル: testexim.py プロジェクト: martindk80/Diamond
    def setUp(self):
        config = get_collector_config('EximCollector', {'interval': 10})

        self.collector = EximCollector(config, None)
        self.collector.COMMAND[0] = 'true'