Skip to content

Commit 4c6ddfe

Browse files
committed
Update tests
1 parent ed0c421 commit 4c6ddfe

3 files changed

Lines changed: 54 additions & 23 deletions

File tree

‎tests/api/common.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def wait_for_queue(self):
9191
break
9292
else:
9393
time.sleep(0.5)
94+
9495
def wait_for_network_state(self, state, multiply=1):
9596
for i in range(0,SLEEP*multiply):
9697
if self.network.state>=state:

‎tests/api/test_controller_command.py‎

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,24 @@
5656

5757
class TestControllerCommand(TestApi):
5858

59-
def test_010_command_send_node_information_nodeid_2(self):
60-
self.wipTest()
61-
ret = self.network.controller.begin_command_send_node_information(2)
59+
def setUp(self):
60+
self.max_delay = 30
61+
self.ctrl_command_result = None
62+
dispatcher.connect(self.ctrl_message, ZWaveController.SIGNAL_CONTROLLER)
63+
self.node_result = None
64+
dispatcher.connect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
65+
66+
def tearDown(self):
67+
self.network.controller.cancel_command()
68+
dispatcher.disconnect(self.ctrl_message, ZWaveController.SIGNAL_CONTROLLER)
69+
dispatcher.disconnect(self.node_update, ZWaveNetwork.SIGNAL_NODE)
70+
71+
def test_010_command_send_node_information_nodeid(self):
72+
node_id = max(self.network.nodes.keys())
73+
ret = self.network.controller.begin_command_send_node_information(node_id)
6274
self.assertTrue(ret)
6375
current = None
64-
for i in range(0,SLEEP*3):
76+
for i in range(0,SLEEP*2):
6577
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
6678
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
6779
current = self.ctrl_command_result
@@ -72,12 +84,12 @@ def test_010_command_send_node_information_nodeid_2(self):
7284
time.sleep(1.0)
7385
self.assertEqual(current, "Completed")
7486

75-
def test_020_command_send_node_information_nodeid_1(self):
76-
self.wipTest()
77-
ret = self.network.controller.begin_command_send_node_information(1)
87+
def test_020_command_send_node_information_nodeid_controller(self):
88+
node_id = self.network.controller.node_id
89+
ret = self.network.controller.begin_command_send_node_information(node_id)
7890
self.assertTrue(ret)
7991
current = None
80-
for i in range(0,SLEEP*3):
92+
for i in range(0,SLEEP*2):
8193
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
8294
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
8395
current = self.ctrl_command_result
@@ -86,14 +98,14 @@ def test_020_command_send_node_information_nodeid_1(self):
8698
break
8799
else:
88100
time.sleep(1.0)
89-
self.assertEqual(current, "Completed")
101+
self.assertEqual(current, "Failed")
90102

91103
def test_110_command_request_network_update(self):
92104
self.wipTest()
93105
ret = self.network.controller.begin_command_request_network_update()
94106
self.assertTrue(ret)
95107
current = None
96-
for i in range(0,SLEEP*3):
108+
for i in range(0,SLEEP*2):
97109
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
98110
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
99111
current = self.ctrl_command_result
@@ -105,11 +117,11 @@ def test_110_command_request_network_update(self):
105117
self.assertEqual(current, "Completed")
106118

107119
def test_210_command_request_node_neigbhor_update_node(self):
108-
self.wipTest()
109-
ret = self.network.controller.begin_command_request_node_neigbhor_update(2)
120+
node_id = max(self.network.nodes.keys())
121+
ret = self.network.controller.begin_command_request_node_neigbhor_update(node_id)
110122
self.assertTrue(ret)
111123
current = None
112-
for i in range(0,SLEEP*3):
124+
for i in range(0,SLEEP*2):
113125
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
114126
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
115127
current = self.ctrl_command_result
@@ -121,11 +133,11 @@ def test_210_command_request_node_neigbhor_update_node(self):
121133
self.assertEqual(current, "Completed")
122134

123135
def test_220_command_request_node_neigbhor_update_controller(self):
124-
self.wipTest()
125-
ret = self.network.controller.begin_command_request_node_neigbhor_update(1)
136+
node_id = self.network.controller.node_id
137+
ret = self.network.controller.begin_command_request_node_neigbhor_update(node_id)
126138
self.assertTrue(ret)
127139
current = None
128-
for i in range(0,SLEEP*3):
140+
for i in range(0,SLEEP*2):
129141
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
130142
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
131143
current = self.ctrl_command_result
@@ -134,14 +146,32 @@ def test_220_command_request_node_neigbhor_update_controller(self):
134146
break
135147
else:
136148
time.sleep(1.0)
137-
self.assertEqual(current, "Failed")
149+
self.assertEqual(current, "Completed")
138150

139151
def test_910_command_command_replication_send(self):
140152
self.wipTest()
141-
ret = self.network.controller.begin_command_replication_send(1)
153+
node_id = max(self.network.nodes.keys())
154+
ret = self.network.controller.begin_command_replication_send(node_id)
155+
self.assertTrue(ret)
156+
current = None
157+
for i in range(0,SLEEP*2):
158+
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
159+
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
160+
current = self.ctrl_command_result
161+
print(current)
162+
self.ctrl_command_result = None
163+
break
164+
else:
165+
time.sleep(1.0)
166+
self.assertEqual(current, "Completed")
167+
168+
def test_920_command_command_replication_send_controller(self):
169+
self.wipTest()
170+
node_id = self.network.controller.node_id
171+
ret = self.network.controller.begin_command_replication_send(node_id)
142172
self.assertTrue(ret)
143173
current = None
144-
for i in range(0,SLEEP*3):
174+
for i in range(0,SLEEP*2):
145175
#print("self.ctrl_command_result = %s" % self.ctrl_command_result)
146176
if self.ctrl_command_result != None and self.ctrl_command_result != "InProgress":
147177
current = self.ctrl_command_result

‎tests/web/common.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
from tests.common import SLEEP
3939
from tests.common import TestPyZWave
40-
import threading
40+
#import threading
4141

4242
from multiprocessing import Process
4343
#from threading import Thread
@@ -50,7 +50,7 @@ def __init__(self):
5050
self.app = None
5151
self.client = None
5252
self.app, self.socketio = create_app(config_object='pyozwweb.config.TestingConfig')
53-
self._stopevent = threading.Event( )
53+
#self._stopevent = threading.Event( )
5454

5555
def run(self):
5656
"""The running method"""
@@ -62,8 +62,8 @@ def stop(self):
6262
"""Stop the tread"""
6363
print 'got stop'
6464
Process.terminate(self)
65-
#time.sleep(2.0)
66-
self._stopevent.wait(2.0)
65+
time.sleep(2.0)
66+
#self._stopevent.wait(2.0)
6767
self.socketio = None
6868
self.app = None
6969
self.client = None

0 commit comments

Comments
 (0)