Exemple #1
0
 def create_mock(self, smart_system):
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_locations()
     api_mock.register_devices()
     api_mock.mount(smart_system)
     return api_mock
Exemple #2
0
 def setup_method(self, method):
     self.smart_system_test_info = SmartSystemFixture.get_smart_system_fixture()
     api_mock = GardenaApiMock()
     self.m_sessions = api_mock.register_sessions()
     self.m_locations = api_mock.register_locations()
     self.m_devices = api_mock.register_devices()
     api_mock.mount(self.smart_system_test_info)
     self.smart_system_test_info.authenticate()
 def test_update_locations(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     print("Taille test : " + str(len(smart_system.locations)))
     api_mock = GardenaApiMock()
     m_sessions = api_mock.register_sessions()
     m_locations = api_mock.register_locations()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     assert len(smart_system.locations) == 1
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             name == location_return["name"])
     assert m_sessions.call_count == 1
     assert m_locations.call_count == 1
 def test_get_all_powers(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_two_locations()
     m_devices = api_mock.register_devices()
     m_devices_2 = api_mock.register_second_location_devices()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     smart_system.update_all_devices()
     assert len(smart_system.get_all_powers()) == 2
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             powers["c6e981e9-8ec6-438f-b400-c720d7f313c8"].name == "Power")
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             id == location_return_two["id"])
     assert (
         smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
         powers["c6e981e9-8ec6-438f-b400-c720d7f313c9"].name == "Power 2")
     assert m_devices.call_count == 1
     assert m_devices_2.call_count == 1
 def test_get_all_mowers(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_two_locations()
     m_devices = api_mock.register_devices()
     m_devices_2 = api_mock.register_second_location_devices()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     smart_system.update_all_devices()
     assert len(smart_system.get_all_mowers()) == 2
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             mowers["e3c1b615-7351-25fc-a551-1908254a2b3e"].name == "Rosi")
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             id == location_return_two["id"])
     assert (
         smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
         mowers["e3c1b615-7351-25fc-a551-1908254a2b3f"].name == "Rosi 2")
     assert m_devices.call_count == 1
     assert m_devices_2.call_count == 1
 def test_get_all_water_controls(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_two_locations()
     m_devices = api_mock.register_devices()
     m_devices_2 = api_mock.register_second_location_devices()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     smart_system.update_all_devices()
     assert len(smart_system.get_all_water_controls()) == 2
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             water_controls["d6259669-3241-488c-a88e-bcf3a07a58bf"].name ==
             "Water Control")
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             id == location_return_two["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             water_controls["d6259669-3241-488c-a88e-bcf3a07a58c0"].name ==
             "Water Control 2")
     assert m_devices.call_count == 1
     assert m_devices_2.call_count == 1
 def test_get_all_sensors(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_two_locations()
     m_devices = api_mock.register_devices()
     m_devices_2 = api_mock.register_second_location_devices()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     smart_system.update_all_devices()
     assert len(smart_system.get_all_sensors()) == 2
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (
         smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
         sensors["a130596e-6627-4030-aea5-b6d2f24d0e03"].name == "Sensor")
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             id == location_return_two["id"])
     assert (
         smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
         sensors["a130596e-6627-4030-aea5-b6d2f24d0e04"].name == "Sensor 2")
     assert m_devices.call_count == 1
     assert m_devices_2.call_count == 1
 def test_get_all_gateways(self):
     smart_system = SmartSystem(email="*****@*****.**", password="******")
     api_mock = GardenaApiMock()
     api_mock.register_sessions()
     api_mock.register_two_locations()
     m_devices = api_mock.register_devices()
     m_devices_2 = api_mock.register_second_location_devices()
     api_mock.mount(smart_system)
     smart_system.authenticate()
     smart_system.update_locations()
     smart_system.update_all_devices()
     assert len(smart_system.get_all_gateways()) == 2
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             id == location_return["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1377"].
             gateways["75cfc1f8-a20c-51d6-c5ea-1b5ecdde80c1"].name ==
             "Gardena Zentrale")
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             id == location_return_two["id"])
     assert (smart_system.locations["1c8b301f-22c8-423d-1b4d-ec25315d1378"].
             gateways["75cfc1f8-a20c-51d6-c5ea-1b5ecdde80c2"].name ==
             "Gardena Zentrale 2")
     assert m_devices.call_count == 1
     assert m_devices_2.call_count == 1