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)
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)
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))
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'))
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))
def test_get_device_for_nonexistant_app_device(self): self.__setup_database() self.assertIsNone( App.get_device('non-existant-app', 'nonexistant-device'))
def test_get_device_for_nonexistant_app_and_device_empty_db(self): self.assertIsNone( App.get_device('non-existant-app', 'nonexistant-device'))
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'), [])
def test_get_all_devices_for_nonexistant_app_empty_db(self): self.assertListEqual(App.get_all_devices_for_app('non-existant-app'), [])
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'), [])
def get_all_devices(self): """ Gets all the devices associated with this app """ return _App.get_all_devices_for_app(self.app)
def get_device(self): """ Gets the device associated with this app """ return _App.get_device(self.app, self.device)
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)
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)
def __init__(self, name=None, device=None): self.is_running = False App.__init__(self, name, device)