def test_check_http_unsupported_method(self): ServiceCheck.consul_version = (0, 8, 4) params = self.params_http del params['body'] check = ServiceCheck.http(self.dummyservice, params) # method isn't supported, check should be None self.assertIsNone(check)
def test_check_http(self): params = self.params_http check = ServiceCheck.http(self.dummyservice, params) self.assertEqual(check['http'], 'http://6.6.6.6:666/path') self.assertEqual(check['interval'], '17s') self.assertEqual(check['timeout'], '3s') self.assertEqual(check['header'], {'x-foo': ['bar', 'baz']}) self.assertEqual(check['Method'], 'HEAD') self.assertEqual(check['Body'], params['body']) self.assertEqual(check['DeregisterCriticalServiceAfter'], '666s') self.assertEqual(check['Status'], 'passing') self.assertEqual(len(check), 8)
def test_check_http_invalid_header(self): params = self.params_http params['header'] = 'invalid_json' check = ServiceCheck.http(self.dummyservice, params) self.assertNotIn('header', check)
def test_check_http_unsupported_body(self): ServiceCheck.consul_version = (1, 0, 0) params = self.params_http check = ServiceCheck.http(self.dummyservice, params) # body isn't supported, check should be None self.assertIsNone(check)
def test_check_http_no_body(self): params = self.params_http del params['body'] check = ServiceCheck.http(self.dummyservice, params) self.assertNotIn('Body', check)
def test_check_http_no_method(self): params = self.params_http del params['http_method'] check = ServiceCheck.http(self.dummyservice, params) self.assertNotIn('Method', check)
def test_check_http_no_path(self): params = self.params_http params['http'] = '' check = ServiceCheck.http(self.dummyservice, params) self.assertIsNone(check)