// Test if started = False
homekit.stop()
self.assertFalse(homekit.driver.stop.called)
// Test if driver not started
homekit.started = True
homekit.driver.configure_mock(**{"run_sentinel": None})
After Change
self.assertEqual(homekit.status, STATUS_READY)
homekit.stop()
self.hass.block_till_done()
homekit.status = STATUS_WAIT
homekit.stop()
self.hass.block_till_done()
homekit.status = STATUS_STOPPED
homekit.stop()
self.hass.block_till_done()
self.assertFalse(homekit.driver.stop.called)
// Test if driver is started
homekit.status = STATUS_RUNNING
homekit.stop()
self.hass.block_till_done()
self.assertTrue(homekit.driver.stop.called)