Esempio n. 1
0
 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()
Esempio n. 2
0
 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
Esempio n. 3
0
 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()
Esempio n. 4
0
 def test_location_information(self):
     location = Location(smart_system=self.smart_system_test_info)
     location.update_information(location_return)
     assert location.id == location_return["id"]
     assert location.name == location_return["name"]
     assert location.latitude == location_return["geo_position"]["latitude"]
     assert location.longitude == location_return["geo_position"]["longitude"]
     assert location.address == location_return["geo_position"]["address"]
     assert location.city == location_return["geo_position"]["city"]
     assert location.sunrise == location_return["geo_position"]["sunrise"]
     assert location.sunset == location_return["geo_position"]["sunset"]
     assert location.time_zone == location_return["geo_position"]["time_zone"]
     assert (
         location.time_zone_offset
         == location_return["geo_position"]["time_zone_offset"]
     )
Esempio n. 5
0
 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