Skip to content

Commit

Permalink
Fix pep8 on test files
Browse files Browse the repository at this point in the history
  • Loading branch information
David Durieux committed Sep 12, 2016
1 parent 8778a40 commit f2254e3
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 43 deletions.
22 changes: 11 additions & 11 deletions test/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ def test_conf_dependencies(self):
# test test_host_00.test_ok_1 -> test_host_00
# test test_host_00.test_ok_1 -> test_host_00.test_ok_0
svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_00",
"test_ok_1")
for (dep_id, status, n_type, _, _) in svc.act_depend_of:
"test_ok_1")
for (dep_id, _, n_type, _, _) in svc.act_depend_of:
if n_type == 'network_dep':
self.assertEqual(self.schedulers[0].sched.hosts[dep_id].host_name, 'test_host_00')
elif n_type == 'logic_dep':
Expand All @@ -75,8 +75,8 @@ def test_conf_dependencies(self):

# test test_host_11.test_parent_svc -> test_host_11.test_son_svc
svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_11",
"test_parent_svc")
for (dep_id, status, n_type, _, _) in svc.act_depend_of:
"test_parent_svc")
for (dep_id, _, n_type, _, _) in svc.act_depend_of:
if n_type == 'network_dep':
self.assertEqual(self.schedulers[0].sched.hosts[dep_id].host_name, 'test_host_11')
elif n_type == 'logic_dep':
Expand All @@ -85,8 +85,8 @@ def test_conf_dependencies(self):

# test test_host_11.test_ok_1 -> test_host_11.test_ok_0
svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_11",
"test_ok_1")
for (dep_id, status, n_type, _, _) in svc.act_depend_of:
"test_ok_1")
for (dep_id, _, n_type, _, _) in svc.act_depend_of:
if n_type == 'network_dep':
self.assertEqual(self.schedulers[0].sched.hosts[dep_id].host_name, 'test_host_11')
elif n_type == 'logic_dep':
Expand Down Expand Up @@ -184,7 +184,7 @@ def test_service_host_case_1(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_00",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_service_host_host(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_00",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -295,7 +295,7 @@ def test_multi_services(self):
host.event_handler_enabled = False

svc1 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_00",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc1.notification_interval = 0.001
svc1.checks_in_progress = []
Expand Down Expand Up @@ -340,7 +340,7 @@ def test_passive_service_not_check_passive_host(self):

host = self.schedulers[0].sched.hosts.find_by_name("test_host_E")
svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_E",
"test_ok_0")
"test_ok_0")

self.scheduler_loop(1, [[host, 0, 'UP'], [svc, 0, 'OK']])

Expand All @@ -362,7 +362,7 @@ def test_passive_service_check_active_host(self):

host = self.schedulers[0].sched.hosts.find_by_name("test_host_00")
svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_00",
"test_passive_0")
"test_passive_0")

self.scheduler_loop(1, [[host, 0, 'UP'], [svc, 0, 'OK']])

Expand Down
3 changes: 0 additions & 3 deletions test/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,9 @@ def test_simple_scheduler_spare(self):

self.setup_with_file('cfg/cfg_dispatcher_scheduler_spare.cfg')
master_index = -1
spare_index = -1
for index, scheduler in enumerate(self.schedulers):
if hasattr(scheduler, 'conf'):
master_index = index
else:
spare_index = index
self.assertGreater(master_index, -1)

json_managed = {self.schedulers[master_index].conf.uuid:
Expand Down
12 changes: 6 additions & 6 deletions test/test_eventhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_ok_critical_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_ok_warning_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down Expand Up @@ -166,7 +166,7 @@ def test_ok_warning_critical_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down Expand Up @@ -249,7 +249,7 @@ def test_ok_warning_s_critical_h_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_ok_critical_s_warning_h_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_ok_critical_s_warning_h_warning_h_ok(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults
svc.enable_notifications = False
Expand Down
18 changes: 9 additions & 9 deletions test/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_0_nonotif(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.checks_in_progress = []
svc.act_depend_of = [] # no hostchecks on critical checkresults

Expand Down Expand Up @@ -86,7 +86,7 @@ def test_1_nonotif_enablewithcmd(self):
host.act_depend_of = [] # ignore the router

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_2_notifications(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -215,7 +215,7 @@ def test_3_notifications(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -271,7 +271,7 @@ def test_4_notifications(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -321,7 +321,7 @@ def test_notifications_with_delay(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
svc.notification_interval = 0.001 # and send immediately then
svc.first_notification_delay = 0.1 # set 6s for first notification delay
svc.checks_in_progress = []
Expand Down Expand Up @@ -395,7 +395,7 @@ def test_notifications_outside_period(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -441,7 +441,7 @@ def test_notifications_ack(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down Expand Up @@ -507,7 +507,7 @@ def test_notifications_downtime(self):
host.event_handler_enabled = False

svc = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_0",
"test_ok_0")
"test_ok_0")
# To make tests quicker we make notifications send very quickly
svc.notification_interval = 0.001
svc.checks_in_progress = []
Expand Down
24 changes: 12 additions & 12 deletions test/test_passive_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def test_1_freshness_state(self):
host_d = self.schedulers[0].sched.hosts.find_by_name("test_host_D")

svc0 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_0")
"test_ok_0")
svc1 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_1")
"test_ok_1")
svc2 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_2")
"test_ok_2")
svc3 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_3")
"test_ok_3")
svc4 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_4")
"test_ok_4")

self.assertEqual("d", host_a.freshness_state)
self.assertEqual("u", host_b.freshness_state)
Expand Down Expand Up @@ -115,15 +115,15 @@ def test_2_freshness_expiration(self):
host_d.last_state_update = int(time.time()) - 10000

svc0 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_0")
"test_ok_0")
svc1 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_1")
"test_ok_1")
svc2 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_2")
"test_ok_2")
svc3 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_3")
"test_ok_3")
svc4 = self.schedulers[0].sched.services.find_srv_by_name_and_hostname("test_host_A",
"test_ok_4")
"test_ok_4")

svc0.last_state_update = int(time.time()) - 10000
svc1.last_state_update = int(time.time()) - 10000
Expand All @@ -149,8 +149,8 @@ def test_2_freshness_expiration(self):
self.assertEqual("UP", host_c.state)
self.assertEqual("DOWN", host_d.state)

all = [svc0, svc1, svc2, svc3, svc4, host_a, host_b, host_c, host_d]
for item in all:
items = [svc0, svc1, svc2, svc3, svc4, host_a, host_b, host_c, host_d]
for item in items:
self.assertEqual("Freshness period expired", item.output)

self.assert_actions_count(0)
Expand Down
3 changes: 1 addition & 2 deletions test/test_unserialize_in_daemons.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
This file test unserialisation of data
"""


import unittest

from alignak import bin

from alignak.misc.serialization import unserialize


Expand Down

0 comments on commit f2254e3

Please sign in to comment.