def post(self): asset = prepare_asset_v1_2(request) if url_fails(asset['uri']): raise Exception("Could not retrieve file. Check the asset URL.") with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) ids_of_active_assets = [x['asset_id'] for x in assets if x['is_active']] asset = assets_helper.create(conn, asset) if asset['is_active']: ids_of_active_assets.insert(asset['play_order'], asset['asset_id']) assets_helper.save_ordering(conn, ids_of_active_assets) return assets_helper.read(conn, asset['asset_id']), 201
def post(self): request_environ = Request(request.environ) asset = prepare_asset_v1_2(request_environ, unique_name=True) if not asset['skip_asset_check'] and url_fails(asset['uri']): raise Exception("Could not retrieve file. Check the asset URL.") with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) ids_of_active_assets = [x['asset_id'] for x in assets if x['is_active']] asset = assets_helper.create(conn, asset) if asset['is_active']: ids_of_active_assets.insert(asset['play_order'], asset['asset_id']) assets_helper.save_ordering(conn, ids_of_active_assets) return assets_helper.read(conn, asset['asset_id']), 201
def test_edit_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '.edit-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="duration"]', lambda field: field.fill('333')) sleep(1) # wait for new-asset panel animation wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['duration'], u'333')
def test_add_asset_streaming(self): with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do( browser, 'input[name="uri"]', lambda field: field.fill( 'rtmp://localhost:1935/app/video.flv')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(10) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['uri'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['mimetype'], u'streaming') self.assertEqual(asset['duration'], settings['default_streaming_duration'])
def test_add_asset_url(self): with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="uri"]', lambda field: field.fill('http://example.com')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'http://example.com') self.assertEqual(asset['uri'], u'http://example.com') self.assertEqual(asset['mimetype'], u'webpage') self.assertEqual(asset['duration'], settings['default_duration'])
def test_add_asset_streaming(self): with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="uri"]', lambda field: field.fill('rtmp://localhost:1935/app/video.flv')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(10) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['uri'], u'rtmp://localhost:1935/app/video.flv') self.assertEqual(asset['mimetype'], u'streaming') self.assertEqual(asset['duration'], settings['default_streaming_duration'])
def test_add_asset_url(self): with Browser() as browser: browser.visit('http://localhost:8080') wait_for_and_do(browser, '#add-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="uri"]', lambda field: field.fill('http://example.com')) wait_for_and_do(browser, 'input[name="duration"]', lambda field: field.fill('30')) sleep(1) wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'http://example.com') self.assertEqual(asset['uri'], u'http://example.com') self.assertEqual(asset['mimetype'], u'webpage') self.assertEqual(asset['duration'], u'30')
def test_add_asset_video_upload(self): video_file = '/tmp/video.mov' with Browser() as browser: browser.visit('http://localhost:8080') browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(video_file)) sleep(1) # wait for new-asset panel animation wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['name'], u'video.mov') self.assertEqual(asset['mimetype'], u'video') self.assertEqual(asset['duration'], u'33')
def get(self, asset_id): with db.conn(settings['database']) as conn: asset = assets_helper.read(conn, asset_id) if isinstance(asset, list): raise Exception('Invalid asset ID provided') if path.isfile(asset['uri']): filename = asset['name'] with open(asset['uri'], 'rb') as f: content = f.read() mimetype = guess_type(filename)[0] if not mimetype: mimetype = 'application/octet-stream' result = { 'type': 'file', 'filename': filename, 'content': b64encode(content), 'mimetype': mimetype } else: result = { 'type': 'url', 'url': asset['uri'] } return result
def test_edit_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit('http://localhost:8080') wait_for_and_do(browser, '.edit-asset-button', lambda btn: btn.click()) sleep(1) wait_for_and_do(browser, 'input[name="duration"]', lambda field: field.fill('333')) sleep(1) # wait for new-asset panel animation wait_for_and_do(browser, '#add-form', lambda form: form.click()) sleep(1) wait_for_and_do(browser, '#save-asset', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['duration'], u'333')
def test_add_two_assets_upload(self): video_file = '/tmp/video.flv' image_file = '/tmp/image.png' with Browser() as browser: browser.visit(main_page_url) browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(image_file)) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(video_file)) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 2) self.assertEqual(assets[0]['name'], u'image.png') self.assertEqual(assets[0]['mimetype'], u'image') self.assertEqual(assets[0]['duration'], settings['default_duration']) self.assertEqual(assets[1]['name'], u'video.flv') self.assertEqual(assets[1]['mimetype'], u'video') self.assertEqual(assets[1]['duration'], u'54')
def test_add_two_assets_upload(self): video_file = '/tmp/video.flv' image_file = '/tmp/image.png' with Browser() as browser: browser.visit(main_page_url) browser.find_by_id('add-asset-button').click() sleep(1) wait_for_and_do(browser, 'a[href="#tab-file_upload"]', lambda tab: tab.click()) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(image_file)) wait_for_and_do(browser, 'input[name="file_upload"]', lambda input: input.fill(video_file)) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 2) self.assertEqual(assets[0]['name'], u'image.png') self.assertEqual(assets[0]['mimetype'], u'image') self.assertEqual(assets[0]['duration'], settings['default_duration']) self.assertEqual(assets[1]['name'], u'video.flv') self.assertEqual(assets[1]['mimetype'], u'video') self.assertEqual(assets[1]['duration'], u'54')
def get(self, asset_id): with db.conn(settings['database']) as conn: asset = assets_helper.read(conn, asset_id) if isinstance(asset, list): raise Exception('Invalid asset ID provided') if path.isfile(asset['uri']): filename = asset['name'] with open(asset['uri'], 'rb') as f: content = f.read() mimetype = guess_type(filename)[0] if not mimetype: mimetype = 'application/octet-stream' result = { 'type': 'file', 'filename': filename, 'content': b64encode(content), 'mimetype': mimetype } else: result = {'type': 'url', 'url': asset['uri']} return result
def put(self, asset_id): asset = prepare_asset_v1_2(request, asset_id) with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) ids_of_active_assets = [x['asset_id'] for x in assets if x['is_active']] asset = assets_helper.update(conn, asset_id, asset) try: ids_of_active_assets.remove(asset['asset_id']) except ValueError: pass if asset['is_active']: ids_of_active_assets.insert(asset['play_order'], asset['asset_id']) assets_helper.save_ordering(conn, ids_of_active_assets) return assets_helper.read(conn, asset_id)
def test_create_update_read_asset_utf8(self): assets_helper.create(self.conn, asset_w) asset_w_ = asset_w.copy() asset_w_.update(**asset_w_diff) assets_helper.update(self.conn, asset_w['asset_id'], asset_w_) should_be_w_ = assets_helper.read(self.conn) self.assertEqual([asset_w_], should_be_w_)
def put(self, asset_id): asset = prepare_asset_v1_2(request, asset_id) with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) ids_of_active_assets = [x['asset_id'] for x in assets if x['is_active']] asset = assets_helper.update(conn, asset_id, asset) try: ids_of_active_assets.remove(asset['asset_id']) except ValueError: pass if asset['is_active']: ids_of_active_assets.insert(asset['play_order'], asset['asset_id']) assets_helper.save_ordering(conn, ids_of_active_assets) return assets_helper.read(conn, asset_id)
def test_create_update_read_asset_utf8(self): assets_helper.create(self.conn, asset_w) asset_w_ = asset_w.copy() asset_w_.update(**asset_w_diff) assets_helper.update(self.conn, asset_w['asset_id'], asset_w_) should_be_w_ = assets_helper.read(self.conn) self.assertEqual([asset_w_], should_be_w_)
def test_set_order_empty(self): assets = [asset_x, asset_y, asset_z] assets_helper.create_multiple(self.conn, assets) assets_helper.save_ordering(self.conn, []) fetched = assets_helper.read(self.conn) self.assertEquals([0, 0, 0], [asset['play_order'] for asset in fetched])
def remove_asset(asset_id): asset = assets_helper.read(db_conn, asset_id) try: if asset['uri'].startswith(settings['assetdir']): os.remove(asset['uri']) except OSError: pass assets_helper.delete(db_conn, asset_id) response.status = 204 # return an OK with no content
def test_create_delete_asset(self): assets_helper.create(self.conn, asset_x) assets_helper.delete(self.conn, asset_x['asset_id']) assets_helper.create(self.conn, asset_y) assets_helper.delete(self.conn, asset_y['asset_id']) should_be_empty = assets_helper.read(self.conn) self.assertEmpty(should_be_empty)
def remove_asset(asset_id): asset = assets_helper.read(db_conn, asset_id) try: if asset['uri'].startswith(settings['assetdir']): os.remove(asset['uri']) except OSError: pass assets_helper.delete(db_conn, asset_id) response.status = 204 # return an OK with no content
def test_create_delete_asset(self): assets_helper.create(self.conn, asset_x) assets_helper.delete(self.conn, asset_x['asset_id']) assets_helper.create(self.conn, asset_y) assets_helper.delete(self.conn, asset_y['asset_id']) should_be_empty = assets_helper.read(self.conn) self.assertEmpty(should_be_empty)
def delete(self, asset_id): with db.conn(settings['database']) as conn: asset = assets_helper.read(conn, asset_id) try: if asset['uri'].startswith(settings['assetdir']): remove(asset['uri']) except OSError: pass assets_helper.delete(conn, asset_id) return '', 204 # return an OK with no content
def test_set_order_empty(self): assets = [asset_x, asset_y, asset_z] assets_helper.create_multiple(self.conn, assets) assets_helper.save_ordering(self.conn, []) fetched = assets_helper.read(self.conn) self.assertEquals([0, 0, 0], [asset['play_order'] for asset in fetched])
def delete(self, asset_id): with db.conn(settings['database']) as conn: asset = assets_helper.read(conn, asset_id) try: if asset['uri'].startswith(settings['assetdir']): remove(asset['uri']) except OSError: pass assets_helper.delete(conn, asset_id) return '', 204 # return an OK with no content
def test_create_update_read_asset(self): assets_helper.create(self.conn, asset_x) asset_x_ = asset_x.copy() asset_x_.update(**asset_x_diff) assets_helper.update(self.conn, asset_x['asset_id'], asset_x_) assets_helper.create(self.conn, asset_y) asset_y_ = asset_y.copy() asset_y_.update(**asset_y_diff) assets_helper.update(self.conn, asset_y['asset_id'], asset_y_) should_be_y__x_ = assets_helper.read(self.conn) self.assertEqual([asset_y_, asset_x_], should_be_y__x_)
def post(self): asset = prepare_asset_v1_2(request) if url_fails(asset['uri']): raise Exception("Could not retrieve file. Check the asset URL.") with db.conn(settings['database']) as conn: if (asset['mimetype'] == 'presentation' or asset['mimetype'] == 'pdf'): createMultipleAssetsFromPresentationOrPdf(asset, conn) #return assets_helper.read(conn, asset['asset_id']),201 else: assets = assets_helper.read(conn) ids_of_active_assets = [ x['asset_id'] for x in assets if x['is_active'] ] asset = assets_helper.create(conn, asset) if asset['is_active']: ids_of_active_assets.insert(asset['play_order'], asset['asset_id']) assets_helper.save_ordering(conn, ids_of_active_assets) return assets_helper.read(conn, asset['asset_id']), 201
def test_create_update_read_asset(self): assets_helper.create(self.conn, asset_x) asset_x_ = asset_x.copy() asset_x_.update(**asset_x_diff) assets_helper.update(self.conn, asset_x['asset_id'], asset_x_) assets_helper.create(self.conn, asset_y) asset_y_ = asset_y.copy() asset_y_.update(**asset_y_diff) assets_helper.update(self.conn, asset_y['asset_id'], asset_y_) should_be_y__x_ = assets_helper.read(self.conn) self.assertEqual([asset_y_, asset_x_], should_be_y__x_)
def test_reorder_asset(self): with db.conn(settings['database']) as conn: _asset_x = asset_x.copy() _asset_x['is_enabled'] = 1 assets_helper.create(conn, _asset_x) assets_helper.create(conn, asset_y) with Browser() as browser: browser.visit('http://localhost:8080') asset_x_for_drag = browser.find_by_id(asset_x['asset_id']) sleep(1) asset_y_to_reorder = browser.find_by_id(asset_y['asset_id']) asset_x_for_drag.drag_and_drop(asset_y_to_reorder) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: x = assets_helper.read(conn, asset_x['asset_id']) y = assets_helper.read(conn, asset_y['asset_id']) self.assertEqual(x['play_order'], 0) self.assertEqual(y['play_order'], 1)
def get(self): collector = ZmqCollector.get_instance() publisher = ZmqPublisher.get_instance() publisher.send_to_viewer('current_asset_id') collector_result = collector.recv_json(2000) current_asset_id = collector_result.get('current_asset_id') if not current_asset_id: return [] with db.conn(settings['database']) as conn: return assets_helper.read(conn, current_asset_id)
def test_reorder_asset(self): with db.conn(settings['database']) as conn: _asset_x = asset_x.copy() _asset_x['is_enabled'] = 1 assets_helper.create(conn, _asset_x) assets_helper.create(conn, asset_y) with Browser() as browser: browser.visit(main_page_url) asset_x_for_drag = browser.find_by_id(asset_x['asset_id']) sleep(1) asset_y_to_reorder = browser.find_by_id(asset_y['asset_id']) asset_x_for_drag.drag_and_drop(asset_y_to_reorder) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: x = assets_helper.read(conn, asset_x['asset_id']) y = assets_helper.read(conn, asset_y['asset_id']) self.assertEqual(x['play_order'], 0) self.assertEqual(y['play_order'], 1)
def test_set_order(self): assets = [asset_x, asset_y, asset_z, asset_w] for_order = [asset_y, asset_x] assets_helper.create_multiple(self.conn, assets) assets_helper.save_ordering(self.conn, [asset['asset_id'] for asset in for_order]) fetched = assets_helper.read(self.conn) self.assertEquals([(0, asset_y['asset_id']), (1, asset_x['asset_id']), (2, asset_z['asset_id']), (2, asset_w['asset_id'])], [(asset['play_order'], asset['asset_id']) for asset in fetched])
def test_rm_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '.delete-asset-button', lambda btn: btn.click()) wait_for_and_do(browser, '.confirm-delete', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 0)
def test_rm_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit('http://localhost:8080') wait_for_and_do(browser, '.delete-asset-button', lambda btn: btn.click()) wait_for_and_do(browser, '.confirm-delete', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 0)
def get(self): collector = ZmqCollector.get_instance() publisher = ZmqPublisher.get_instance() publisher.send_to_viewer('current_asset_id') collector_result = collector.recv_json(2000) current_asset_id = collector_result.get('current_asset_id') if not current_asset_id: return [] with db.conn(settings['database']) as conn: return assets_helper.read(conn, current_asset_id)
def test_enable_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, '.toggle', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['is_enabled'], 1)
def test_enable_asset(self): with db.conn(settings['database']) as conn: assets_helper.create(conn, asset_x) with Browser() as browser: browser.visit('http://localhost:8080') wait_for_and_do(browser, 'span[class="on"]', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['is_enabled'], 1)
def test_set_order(self): assets = [asset_x, asset_y, asset_z, asset_w] for_order = [asset_y, asset_x] assets_helper.create_multiple(self.conn, assets) assets_helper.save_ordering(self.conn, [asset['asset_id'] for asset in for_order]) fetched = assets_helper.read(self.conn) self.assertEquals( [(0, asset_y['asset_id']), (1, asset_x['asset_id']), (2, asset_z['asset_id']), (2, asset_w['asset_id'])], [(asset['play_order'], asset['asset_id']) for asset in fetched])
def generate_asset_list(): """Choose deadline via: 1. Map assets to deadlines with rule: if asset is active then 'end_date' else 'start_date' 2. Get nearest deadline """ logging.info('Generating asset-list...') assets = assets_helper.read(db_conn) deadlines = [asset['end_date'] if assets_helper.is_active(asset) else asset['start_date'] for asset in assets] playlist = filter(assets_helper.is_active, assets) deadline = sorted(deadlines)[0] if len(deadlines) > 0 else None logging.debug('generate_asset_list deadline: %s', deadline) if settings['shuffle_playlist']: shuffle(playlist) return playlist, deadline
def generate_asset_list(): """Choose deadline via: 1. Map assets to deadlines with rule: if asset is active then 'end_date' else 'start_date' 2. Get nearest deadline """ logging.info('Generating asset-list...') assets = assets_helper.read(db_conn) deadlines = [asset['end_date'] if assets_helper.is_active(asset) else asset['start_date'] for asset in assets] playlist = filter(assets_helper.is_active, assets) deadline = sorted(deadlines)[0] if len(deadlines) > 0 else None logging.debug('generate_asset_list deadline: %s', deadline) if settings['shuffle_playlist']: shuffle(playlist) return playlist, deadline
def test_disable_asset(self): with db.conn(settings['database']) as conn: _asset_x = asset_x.copy() _asset_x['is_enabled'] = 1 assets_helper.create(conn, _asset_x) with Browser() as browser: browser.visit(main_page_url) wait_for_and_do(browser, 'span[class="off"]', lambda btn: btn.click()) sleep(3) # backend need time to process request with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) self.assertEqual(len(assets), 1) asset = assets[0] self.assertEqual(asset['is_enabled'], 0)
def generate_asset_list(): """Choose deadline via: 1. Map assets to deadlines with rule: if asset is active then 'end_date' else 'start_date' 2. Get nearest deadline """ logging.info('Generating asset-list...') assets = assets_helper.read(db_conn) deadlines = [asset['end_date'] if assets_helper.is_active(asset) else asset['start_date'] for asset in assets] # FIXME: we need a list for the shuffle # should we use list comprehension for playlist, instead of filter()? playlist = list(filter(assets_helper.is_active, assets)) deadline = sorted(deadlines)[0] if len(deadlines) > 0 else None logging.debug('generate_asset_list deadline: %s', deadline) if settings['shuffle_playlist']: random.shuffle(playlist) return playlist, deadline
def get(self, asset_id): with db.conn(settings['database']) as conn: return assets_helper.read(conn, asset_id)
def get(self): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) return assets
def api_assets(): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) return make_json_response(assets)
def test_create_read_asset(self): assets_helper.create(self.conn, asset_x) assets_helper.create(self.conn, asset_y) should_be_y_x = assets_helper.read(self.conn) self.assertEqual([asset_y, asset_x], should_be_y_x)
def setUp(self): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) for asset in assets: assets_helper.delete(conn, asset['asset_id'])
def get(self): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) return assets
def get(self, asset_id): with db.conn(settings['database']) as conn: return assets_helper.read(conn, asset_id)
def edit_asset(asset_id): return assets_helper.read(db_conn, asset_id)
def api_assets(): assets = assets_helper.read(db_conn) return make_json_response(assets)
def get_specific_asset(asset_id): logging.info('Getting specific asset') return assets_helper.read(db_conn, asset_id)
def api_assets(): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) return make_json_response(assets)
def edit_asset(asset_id): return assets_helper.read(db_conn, asset_id)
def get_specific_asset(asset_id): logging.info('Getting specific asset') return assets_helper.read(db_conn, asset_id)
def setUp(self): with db.conn(settings['database']) as conn: assets = assets_helper.read(conn) for asset in assets: assets_helper.delete(conn, asset['asset_id'])
def api_assets(): assets = assets_helper.read(db_conn) return make_json_response(assets)
def test_create_read_asset(self): assets_helper.create(self.conn, asset_x) assets_helper.create(self.conn, asset_y) should_be_y_x = assets_helper.read(self.conn) self.assertEqual([asset_y, asset_x], should_be_y_x)