예제 #1
0
class TestHttpCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config(
            "HttpCollector", {"req_vhost": "www.my_server.com", "req_url": ["http://www.my_server.com/"]}
        )

        self.collector = HttpCollector(config, None)

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

    @patch.object(Collector, "publish")
    def test_should_work_with_real_data(self, publish_mock):
        patch_urlopen = patch("urllib2.urlopen", Mock(return_value=self.getFixture("index")))

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

        metrics = {"http__www_my_server_com_.size": 150}

        self.setDocExample(
            collector=self.collector.__class__.__name__, metrics=metrics, defaultpath=self.collector.config["path"]
        )
        self.assertPublishedMany([publish_mock], metrics)
예제 #2
0
    def setUp(self):
        config = get_collector_config('HttpCollector', {
            'req_vhost': 'www.my_server.com',
            'req_url': ['http://www.my_server.com/']
        })

        self.collector = HttpCollector(config, None)
예제 #3
0
class TestHttpCollector(CollectorTestCase):

    def setUp(self):
        config = get_collector_config('HttpCollector', {
            'req_vhost': 'www.my_server.com',
            'req_url': ['http://www.my_server.com/']
        })

        self.collector = HttpCollector(config, None)

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

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        patch_urlopen = patch('urllib2.urlopen', Mock(
            return_value=self.getFixture('index')))

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

        metrics = {
            'http__www_my_server_com_.size': 150,
        }

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
        self.assertPublishedMany([publish_mock,
                                  ], metrics)
예제 #4
0
파일: testhttp.py 프로젝트: 1and1/Diamond
class TestHttpCollector(CollectorTestCase):
    def setUp(self):
        config = get_collector_config('HttpCollector', {
            'req_vhost': 'www.my_server.com',
            'req_url': ['http://www.my_server.com/']
        })

        self.collector = HttpCollector(config, None)

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

    @patch.object(Collector, 'publish')
    def test_should_work_with_real_data(self, publish_mock):
        patch_urlopen = patch('urllib2.urlopen', Mock(
            return_value=self.getFixture('index')))

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

        metrics = {
            'http__www_my_server_com_.size': 150,
        }

        self.setDocExample(collector=self.collector.__class__.__name__,
                           metrics=metrics,
                           defaultpath=self.collector.config['path'])
        self.assertPublishedMany([publish_mock,
                                  ], metrics)
예제 #5
0
    def setUp(self):
        config = get_collector_config(
            'HttpCollector', {
                'req_vhost':
                'www.my_server.com',
                'req_urls_and_teststrings':
                ['http://www.my_server.com/', 'keep out']
            })

        self.collector = HttpCollector(config, None)
예제 #6
0
파일: testhttp.py 프로젝트: 1and1/Diamond
    def setUp(self):
        config = get_collector_config('HttpCollector', {
            'req_vhost': 'www.my_server.com',
            'req_url': ['http://www.my_server.com/']
        })

        self.collector = HttpCollector(config, None)
예제 #7
0
    def setUp(self):
        config = get_collector_config(
            "HttpCollector", {"req_vhost": "www.my_server.com", "req_url": ["http://www.my_server.com/"]}
        )

        self.collector = HttpCollector(config, None)