Skip to content

Commit

Permalink
Fix some tests modified by mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Apr 26, 2018
1 parent ad3fdaf commit e3420b3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
41 changes: 21 additions & 20 deletions alignak_module_ws/ws.py
Expand Up @@ -987,26 +987,27 @@ def update_host(self, host_name, data):
data.pop('services')

try:
headers = {'Content-Type': 'application/json', 'If-Match': host['_etag']}
logger.info("Updating host '%s': %s", host_name, data)
start = time.time()
patch_result = backend.patch('/'.join(['host', host['_id']]),
data=data, headers=headers, inception=True)
self.statsmgr.counter('backend-patch.host', 1)
self.statsmgr.timer('backend-patch-time.host', time.time() - start)
logger.debug("Backend patch, result: %s", patch_result)
if patch_result['_status'] != 'OK':
logger.warning("Host patch, got a problem: %s", result)
return ('ERR', patch_result['_issues'])

if self.give_feedback:
host = backend.get('/'.join(['host', host['_id']]))
if '_feedback' not in ws_result:
ws_result['_feedback'] = {}
ws_result['_feedback'].update({'name': host['name']})
for prop in host:
if prop in self.feedback_host:
ws_result['_feedback'].update({prop: host[prop]})
if '_etag' in host:
headers = {'Content-Type': 'application/json', 'If-Match': host['_etag']}
logger.info("Updating host '%s': %s", host_name, data)
start = time.time()
patch_result = backend.patch('/'.join(['host', host['_id']]),
data=data, headers=headers, inception=True)
self.statsmgr.counter('backend-patch.host', 1)
self.statsmgr.timer('backend-patch-time.host', time.time() - start)
logger.debug("Backend patch, result: %s", patch_result)
if patch_result['_status'] != 'OK':
logger.warning("Host patch, got a problem: %s", result)
return ('ERR', patch_result['_issues'])

if self.give_feedback:
host = backend.get('/'.join(['host', host['_id']]))
if '_feedback' not in ws_result:
ws_result['_feedback'] = {}
ws_result['_feedback'].update({'name': host['name']})
for prop in host:
if prop in self.feedback_host:
ws_result['_feedback'].update({prop: host[prop]})

if not self.give_feedback and '_feedback' in ws_result:
ws_result.pop('_feedback')
Expand Down
2 changes: 1 addition & 1 deletion test/test_module.py
Expand Up @@ -564,7 +564,7 @@ def test_module_start_parameters(self):
re.escape("StatsD configuration: 127.0.0.1:8888, prefix: test, enabled: True"), idx)
idx += 1
self.assert_log_match(
re.escape("Sending web-services daemon statistics to: 127.0.0.1:8888, prefix: test"), idx)
re.escape("Sending web-services statistics to: 127.0.0.1:8888, prefix: test"), idx)
idx += 1
self.assert_log_match(
re.escape("Trying to contact StatsD server..."), idx)
Expand Down
3 changes: 2 additions & 1 deletion test/test_module_no_backend.py
Expand Up @@ -115,7 +115,7 @@ def test_module_host_livestate_unauthorized(self):
'allow_host_creation': '1',
'allow_service_creation': '1',
# Force Alignak backend update by the module (default is not force!)
'alignak_backend_livestate_update': '1',
'alignak_backend_livestate_update': '0',

# Disable authorization
'authorization': '0'
Expand Down Expand Up @@ -177,6 +177,7 @@ def test_module_host_livestate_unauthorized(self):
}
self.assertEqual(my_module.received_commands, 0)
response = session.patch(self.ws_endpoint + '/host', json=data, headers=headers)
print(response)
self.assertEqual(response.status_code, 200)
result = response.json()
self.assertEqual(result, {
Expand Down

0 comments on commit e3420b3

Please sign in to comment.