def test_setup_failed_connect(self, mock_co2): """Test setup when connection error occurs.""" self.assertFalse( mhz19.setup_platform(self.hass, { 'platform': 'mhz19', mhz19.CONF_SERIAL_DEVICE: 'test.serial', }, None))
def test_setup_connected(self): """Test setup when connection succeeds.""" with patch.multiple('pmsensor.co2sensor', read_mh_z19=DEFAULT, read_mh_z19_with_temperature=DEFAULT): from pmsensor.co2sensor import read_mh_z19_with_temperature read_mh_z19_with_temperature.return_value = None mock_add = Mock() self.assertTrue(mhz19.setup_platform(self.hass, { 'platform': 'mhz19', 'monitored_conditions': ['co2', 'temperature'], mhz19.CONF_SERIAL_DEVICE: 'test.serial', }, mock_add)) self.assertEqual(1, mock_add.call_count)
def test_setup_failed_connect(self, mock_co2): """Test setup when connection error occurs.""" self.assertFalse(mhz19.setup_platform(self.hass, { 'platform': 'mhz19', mhz19.CONF_SERIAL_DEVICE: 'test.serial', }, None))