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_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_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 generate_asset_list(): logging.info('Generating asset-list...') now = datetime.utcnow() enabled_assets = [a for a in assets_helper.read(db_conn) if a['is_enabled']] future_dates = [a[k] for a in enabled_assets for k in ['start_date', 'end_date'] if a[k] > now] deadline = sorted(future_dates)[0] if future_dates else None logging.debug('generate_asset_list deadline: %s', deadline) playlist = assets_helper.get_playlist(db_conn) if settings['shuffle_playlist']: shuffle(playlist) return (playlist, deadline)
def generate_asset_list(): logging.info("Generating asset-list...") now = datetime.utcnow() enabled_assets = [a for a in assets_helper.read(db_conn) if a["is_enabled"]] future_dates = [a[k] for a in enabled_assets for k in ["start_date", "end_date"] if a[k] > now] deadline = sorted(future_dates)[0] if future_dates else None logging.debug("generate_asset_list deadline: %s", deadline) playlist = assets_helper.get_playlist(db_conn) if settings["shuffle_playlist"]: shuffle(playlist) return (playlist, deadline)
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 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)