def test_get_devices_failed(self): smart_system = SmartSystem(email="*****@*****.**", password="******") init_failed_mock(smart_system) smart_system.authenticate() location = Location(smart_system=smart_system) location.update_information(location_return) with pytest.raises(HTTPError): location.update_devices()
def test_update_devices(self): location = Location(smart_system=self.smart_system_test_info) location.update_information(location_return) location.update_devices() assert self.m_devices.call_count == 1 assert len(location.gateways) == 1 assert len(location.mowers) == 1 assert len(location.sensors) == 1 assert len(location.water_controls) == 1 assert len(location.powers) == 1
def test_device_informations(self): location = Location(smart_system=self.smart_system_test_info) location.update_information(location_return) location.update_devices() assert self.m_devices.call_count == 1 assert len(location.gateways) == 1 assert len(location.mowers) == 1 assert "75cfc1f8-a20c-51d6-c5ea-1b5ecdde80c1" in location.gateways.keys() assert "e3c1b615-7351-25fc-a551-1908254a2b3e" in location.mowers.keys() assert "a130596e-6627-4030-aea5-b6d2f24d0e03" in location.sensors.keys() assert "d6259669-3241-488c-a88e-bcf3a07a58bf" in location.water_controls.keys() assert "c6e981e9-8ec6-438f-b400-c720d7f313c8" in location.powers.keys()
def test_update_devices_unknown_category(self): location = Location(smart_system=self.smart_system_test_info) location.update_information(location_return) location.update_devices() assert self.m_devices.call_count == 1 assert len(location.gateways) == 1 assert len(location.mowers) == 1 assert len(location.sensors) == 1 assert len(location.water_controls) == 1 assert len(location.powers) == 1 location.add_or_update_device( device={ "id": "75cfc1f8-a20c-51d6-c5ea-1b5eccce80c1", "name": "Unknown device", "description": "Unknown device", "category": "unknown_category", } ) assert len(location.gateways) == 1 assert len(location.mowers) == 1 assert len(location.sensors) == 1 assert len(location.water_controls) == 1 assert len(location.powers) == 1