def test_dont_request_state_if_not_connected(self, mocked_connect,
                                              mocked_publish):
     device = DysonPureCoolLink({
         "Active":
         True,
         "Serial":
         "device-id-1",
         "Name":
         "device-1",
         "ScaleUnit":
         "SU01",
         "Version":
         "21.03.08",
         "LocalCredentials":
         "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/70ZGysII1K"
         "e1i0ZHakFH84DZuxsSQ4KTT2vbCm7uYeTORULKLKQ==",
         "AutoUpdate":
         True,
         "NewVersionAvailable":
         False,
         "ProductType":
         "475"
     })
     network_device = NetworkDevice('device-1', 'host', 1111)
     device.connection_callback(False)
     device._add_network_device(network_device)
     connected = device.connect(None, "192.168.0.2")
     self.assertFalse(connected)
     self.assertEqual(mocked_connect.call_count, 1)
     device.request_current_state()
     self.assertEqual(mocked_publish.call_count, 0)
     device.request_environmental_state()
     self.assertEqual(mocked_publish.call_count, 0)
 def test_connect_device_with_config_failed(self, mocked_connect,
                                            mocked_loop_start,
                                            mocked_loop_stop):
     device = DysonPureCoolLink({
         "Active":
         True,
         "Serial":
         "device-id-1",
         "Name":
         "device-1",
         "ScaleUnit":
         "SU01",
         "Version":
         "21.03.08",
         "LocalCredentials":
         "1/aJ5t52WvAfn+z+fjDuef86kQDQPefbQ6/"
         "70ZGysII1Ke1i0ZHakFH84DZuxsSQ4KTT2v"
         "bCm7uYeTORULKLKQ==",
         "AutoUpdate":
         True,
         "NewVersionAvailable":
         False,
         "ProductType":
         "475"
     })
     device.connection_callback(False)
     connected = device.connect("192.168.0.2")
     self.assertFalse(connected)
     self.assertIsNone(device.state)
     self.assertEqual(device.network_device.name, "device-1")
     self.assertEqual(device.network_device.address, "192.168.0.2")
     self.assertEqual(device.network_device.port, 1883)
     self.assertEqual(mocked_connect.call_count, 1)
     self.assertEqual(mocked_loop_start.call_count, 1)
     self.assertEqual(mocked_loop_stop.call_count, 1)