Exemplo n.º 1
0
    def test_http_resource_error3(self):
        data = {
            'url': 'https://mottainaici.github.io/lxd-compose-docs/',
        }

        with self.assertRaises(Exception):
            HttpResource(data)
Exemplo n.º 2
0
 def test_probe_resource5(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '500')
     data['method'] = 'POST'
     data['expected_http_code'] = 500
     resource = HttpResource(data)
     self._run_probe(resource, True, None)
Exemplo n.º 3
0
    def test_http_resource_error2(self):
        data = {
            'name': 'url1',
        }

        with self.assertRaises(Exception):
            HttpResource(data)
Exemplo n.º 4
0
 def test_probe_resource3(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '200')
     data['expected_body_pattern'] = '.*Not match.*'
     resource = HttpResource(data)
     self._run_probe(resource, False,
                     "Response body doesn't match expected pattern")
Exemplo n.º 5
0
 def test_probe_resource4(self):
     data = self.get_entity_data()
     data['url'] = "http://127.0.0.1:10001/invalid"
     data['expected_http_code'] = 0
     resource = HttpResource(data)
     self._run_probe(resource, False,
                     "Cannot connect to host 127.0.0.1:10001")
Exemplo n.º 6
0
 def test_http_client3(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '500')
     data['method'] = 'POST'
     data['expected_http_code'] = 500
     resource = HttpResource(data)
     self._run_request(resource, 'Something goes wrong.')
Exemplo n.º 7
0
    def test_http_resource1(self):
        data = {
            'name': "url1-get",
            'url': 'https://www.google.it',
            'method': 'GET',
        }

        obj = HttpResource(data)
        self.assertEqual(obj.name, 'url1-get')
        self.assertEqual(obj.url, 'https://www.google.it')
        self.assertEqual(obj.method, 'GET')
        self.assertEqual(obj.expected_http_code, 200)
Exemplo n.º 8
0
    def test_http_resource4(self):
        data = {
            'name': "url2-get",
            'url': 'https://www.google.it',
            'expected_http_code': 404,
            'expected_body_pattern': '.*Google.*',
        }

        obj = HttpResource(data)
        self.assertEqual(obj.name, 'url2-get')
        self.assertEqual(obj.url, 'https://www.google.it')
        self.assertEqual(obj.method, 'GET')
        self.assertEqual(obj.expected_http_code, 404)
        self.assertEqual(obj.expected_body_pattern, '.*Google.*')
Exemplo n.º 9
0
    def test_http_resource_error1(self):
        data = {}

        with self.assertRaises(Exception):
            HttpResource(data)
Exemplo n.º 10
0
 def test_probe_resource2(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '200')
     data['expected_body_pattern'] = '.*All.*'
     resource = HttpResource(data)
     self._run_probe(resource, True, None)
Exemplo n.º 11
0
 def test_probe_resource1(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '200')
     resource = HttpResource(data)
     self._run_probe(resource, True, None)
Exemplo n.º 12
0
 def test_http_client1(self):
     data = self.get_entity_data()
     data['url'] = '%s%s' % (data['url'], '200')
     data['method'] = 'GET'
     resource = HttpResource(data)
     self._run_request(resource, 'All is ok.')