Skip to content

Commit

Permalink
Update pylint and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf committed Jun 4, 2017
1 parent 6239e25 commit 329815a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 16 deletions.
8 changes: 5 additions & 3 deletions alignak_webui/plugins/actions/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,15 @@ def add_command(self):
# Provide the described parameters
parameters = []
for parameter in commands[command].get('parameters', {}):
if request.forms.get(parameter, None) is None:
parameter_value = request.forms.get(parameter, None)
if parameter_value is None:
logger.error("missing command parameter in the request: %s", parameter)
return self.webui.response_invalid_parameters(
_('Missing parameter: %s' % parameter)
)
parameters.append(request.forms.get(parameter, None))
logger.debug("Command parameters: %s", parameters)
logger.debug("Command parameter: %s = %s", parameter, parameter_value)
parameters.append(parameter_value)
logger.info("Command parameters: %s", parameters)

element_ids = request.forms.getall('element_id')
if not element_ids:
Expand Down
2 changes: 1 addition & 1 deletion alignak_webui/plugins/actions/external_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'process_host_check_result': {
'global': False, 'elements_type': 'host',
'title': _("Send an host check result"),
"parameters": ["ls_state_id", "ls_output"]
"parameters": ["ls_state_id", "ls_output", "ls_long_output", "ls_perf_data"]
},
'process_host_output': {
'global': False, 'elements_type': 'host',
Expand Down
2 changes: 0 additions & 2 deletions alignak_webui/plugins/alignak/settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ editable=False

[table.pid]
editable=false
type=integer
visible=True

[table.program_start]
editable=false
type=integer
format=datetime
visible=True

Expand Down
7 changes: 3 additions & 4 deletions alignak_webui/plugins/worldmap/worldmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ def show_worldmap(self, for_my_widget=False):
# Do not include the embedded fields to improve the loading time...
hosts = datamgr.get_hosts(search, embedded=False)

# Get valid hosts
(positionned_hosts, not_positionned_hosts) = self.get_map_elements(hosts)
# Get positionned and not-positionned hosts
(positionned_hosts, dummy) = self.get_map_elements(hosts)

# Get last total elements count
total = len(positionned_hosts)
Expand Down Expand Up @@ -196,7 +196,7 @@ def show_worldmap(self, for_my_widget=False):
}

def get_map_elements(self, hosts):
# pylint:disable=no-self-use
# pylint:disable=no-self-use, too-many-locals
"""Get hosts valid for a map:
:param hosts: list of hosts to search in
Expand Down Expand Up @@ -307,7 +307,6 @@ def get_map_elements(self, hosts):
else:
not_positionned_hosts.append(map_host)


logger.info("worldmap, found %d positionned hosts and %d not yet positionned",
len(positionned_hosts), len(not_positionned_hosts))

Expand Down
8 changes: 4 additions & 4 deletions test/test_datamanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_2_1_creation_load(self):
print('DM logging bad password')
assert not datamanager.user_login('admin', 'fake')
print(datamanager.connection_message)
assert datamanager.connection_message == 'Backend connection refused...'
assert datamanager.connection_message == 'Access denied! Check your username and password.'
print(datamanager.logged_in_user)
assert not datamanager.logged_in_user

Expand All @@ -155,14 +155,14 @@ def test_2_1_creation_load(self):
print('DM logging bad password')
assert not datamanager.user_login('admin', 'fake')
print(datamanager.connection_message)
assert datamanager.connection_message == 'Backend connection refused...'
assert datamanager.connection_message == 'Access denied! Check your username and password.'
print(datamanager.logged_in_user)
assert not datamanager.logged_in_user

# User login but do not load yet
print('DM login ok')
assert datamanager.user_login('admin', 'admin', load=False)
assert datamanager.connection_message == 'Connection successful'
assert datamanager.connection_message == 'Access granted'
print("Logged user: %s" % datamanager.logged_in_user)
assert datamanager.logged_in_user
assert datamanager.logged_in_user is not None
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_2_1_creation_load(self):
print(datamanager.logged_in_user.token)
user_token = datamanager.logged_in_user.token
assert datamanager.user_login(user_token)
assert datamanager.connection_message == 'Connection successful'
assert datamanager.connection_message == 'Access granted'

assert datamanager.logged_in_user
assert datamanager.logged_in_user is not None
Expand Down
4 changes: 2 additions & 2 deletions test/test_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ def test_login_refused(self):
print('login refused - credentials')
response = self.app.post('/login', {'username': None, 'password': None})
redirected_response = response.follow()
redirected_response.mustcontain('Backend connection refused...')
redirected_response.mustcontain('Access denied! Check your username and password.')

print('login refused - fake credentials')
response = self.app.post('/login', {'username': 'fake', 'password': 'fake'})
redirected_response = response.follow()
redirected_response.mustcontain('Backend connection refused...')
redirected_response.mustcontain('Access denied! Check your username and password.')

# /heartbeat sends a status 401
response = self.app.get('/heartbeat', status=401)
Expand Down

0 comments on commit 329815a

Please sign in to comment.