def test_start_stop_gateway(self):
    'Test start and stop of MQTT gateway.'
    self.assertFalse(self.gateway.is_alive())
    sensor = self._add_sensor(1)
    sensor.children[1] = ChildSensor(1, self.gateway.const.Presentation.S_HUM)
    sensor.children[1].values[self.gateway.const.SetReq.V_HUM] = '20'
    self.gateway.recv('/1/1/2/0/1', '', 0)
    self.gateway.recv('/1/1/1/0/1', '30', 0)
    self.gateway.recv('/1/1/2/0/1', '', 0)
    self.gateway.start()
    self.assertTrue(self.gateway.is_alive())
    calls = [mock.call('/+/+/0/+/+', self.gateway.recv, 0), mock.call('/+/+/3/+/+', self.gateway.recv, 0)]
    self.mock_sub.assert_has_calls(calls)
    time.sleep(0.05)
    calls = [mock.call('/1/1/1/0/1', '20', 0, True), mock.call('/1/1/1/0/1', '30', 0, True)]
    self.mock_pub.assert_has_calls(calls)
    self.gateway.stop()
    self.gateway.join(timeout=0.5)
    self.assertFalse(self.gateway.is_alive())
Test start and stop of MQTT gateway.
def test_start_stop_gateway(self):
    
    self.assertFalse(self.gateway.is_alive())
    sensor = self._add_sensor(1)
    sensor.children[1] = ChildSensor(1, self.gateway.const.Presentation.S_HUM)
    sensor.children[1].values[self.gateway.const.SetReq.V_HUM] = '20'
    self.gateway.recv('/1/1/2/0/1', , 0)
    self.gateway.recv('/1/1/1/0/1', '30', 0)
    self.gateway.recv('/1/1/2/0/1', , 0)
    self.gateway.start()
    self.assertTrue(self.gateway.is_alive())
    calls = [mock.call('/+/+/0/+/+', self.gateway.recv, 0), mock.call('/+/+/3/+/+', self.gateway.recv, 0)]
    self.mock_sub.assert_has_calls(calls)
    time.sleep(0.05)
    calls = [mock.call('/1/1/1/0/1', '20', 0, True), mock.call('/1/1/1/0/1', '30', 0, True)]
    self.mock_pub.assert_has_calls(calls)
    self.gateway.stop()
    self.gateway.join(timeout=0.5)
    self.assertFalse(self.gateway.is_alive())