示例#1
0
 def test_get_all_devices_for_existing_app_with_devices(self):
     devices = ['dev1', 'dev2', '', 'dev3']
     flaskserver.running_context.db.session.add(
         flaskserver.running_context.App(app='App1', devices=devices))
     flaskserver.running_context.db.session.commit()
     orderless_list_compare(
         self,
         [device.name
          for device in App.get_all_devices_for_app('App1')], devices)
示例#2
0
 def test_get_device_for_existant_app_with_devices(self):
     self.__setup_database()
     app_devices = {'App2': ['a', 'b'], 'App3': ['a', 'c', 'd']}
     for app_name, devices in app_devices.items():
         for device_name in devices:
             device = App.get_device(app_name, device_name)
             self.assertIsInstance(device,
                                   flaskserver.running_context.Device)
             self.assertEqual(device.name, device_name)
示例#3
0
 def test_get_device_for_existant_app_no_devices(self):
     self.__setup_database()
     for device_name in ['a', 'b', 'c', 'd']:
         self.assertIsNone(App.get_device('App1', device_name))
示例#4
0
 def test_get_device_for_existant_app_nonexistant_device(self):
     self.__setup_database()
     for app_name in ['App1', 'App2', 'App3']:
         self.assertIsNone(App.get_device(app_name, 'non-existant-device'))
示例#5
0
 def test_get_device_for_nonexistant_app_existing_device(self):
     self.__setup_database()
     for device_name in ['a', 'b', 'c', 'd']:
         self.assertIsNone(App.get_device('non-existiant-app', device_name))
示例#6
0
 def test_get_device_for_nonexistant_app_device(self):
     self.__setup_database()
     self.assertIsNone(
         App.get_device('non-existant-app', 'nonexistant-device'))
示例#7
0
 def test_get_device_for_nonexistant_app_and_device_empty_db(self):
     self.assertIsNone(
         App.get_device('non-existant-app', 'nonexistant-device'))
示例#8
0
 def test_get_all_devices_for_existing_app_with_no_devices(self):
     flaskserver.running_context.db.session.add(
         flaskserver.running_context.App(app='App1', devices=[]))
     flaskserver.running_context.db.session.commit()
     self.assertListEqual(App.get_all_devices_for_app('App1'), [])
示例#9
0
 def test_get_all_devices_for_nonexistant_app_empty_db(self):
     self.assertListEqual(App.get_all_devices_for_app('non-existant-app'),
                          [])
示例#10
0
 def test_get_all_devices_for_nonexistant_app_full_db(self):
     for app_name in ['App1', 'App2', 'App3']:
         flaskserver.running_context.db.session.add(
             flaskserver.running_context.App(app=app_name, devices=[]))
     flaskserver.running_context.db.session.commit()
     self.assertListEqual(App.get_all_devices_for_app('App4'), [])
示例#11
0
 def get_all_devices(self):
     """ Gets all the devices associated with this app """
     return _App.get_all_devices_for_app(self.app)
示例#12
0
 def get_device(self):
     """ Gets the device associated with this app """
     return _App.get_device(self.app, self.device)
示例#13
0
 def get_device(self):
     """ Gets the device associated with this app """
     from server.appdevice import App as _App
     return _App.get_device(self.app, self.device)
示例#14
0
 def get_all_devices(self):
     """ Gets all the devices associated with this app """
     from server.appdevice import App as _App
     return _App.get_all_devices_for_app(self.app)
示例#15
0
 def __init__(self, name=None, device=None):
     self.is_running = False
     App.__init__(self, name, device)