def test_http_resource_error3(self): data = { 'url': 'https://mottainaici.github.io/lxd-compose-docs/', } with self.assertRaises(Exception): HttpResource(data)
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)
def test_http_resource_error2(self): data = { 'name': 'url1', } with self.assertRaises(Exception): HttpResource(data)
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")
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")
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.')
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)
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.*')
def test_http_resource_error1(self): data = {} with self.assertRaises(Exception): HttpResource(data)
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)
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)
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.')