示例#1
0
    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_)
示例#2
0
    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_)
示例#3
0
    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)
示例#4
0
    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)
示例#5
0
    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_)
示例#6
0
    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_)
示例#7
0
    def test_get_playlist(self):
        assets_helper.create(self.conn, asset_x)
        assets_helper.create(self.conn, asset_y)

        self.set_now(date_e)
        should_be_empty = assets_helper.get_playlist(self.conn)
        self.assertEmpty(should_be_empty)

        self.set_now(date_f)
        [should_be_x] = assets_helper.get_playlist(self.conn)
        self.assertEqual(asset_x['asset_id'], should_be_x['asset_id'])

        self.set_now(date_g)
        should_be_y_x = assets_helper.get_playlist(self.conn)
        self.assertEqual(
            [should_be_y_x[0]['asset_id'], should_be_y_x[1]['asset_id']],
            [asset_y['asset_id'], asset_x['asset_id']])

        self.set_now(date_h)
        [should_be_y] = assets_helper.get_playlist(self.conn)
        self.assertEqual(asset_y['asset_id'], should_be_y['asset_id'])
示例#8
0
    def test_get_playlist(self):
        assets_helper.create(self.conn, asset_x)
        assets_helper.create(self.conn, asset_y)

        self.set_now(date_e)
        should_be_empty = assets_helper.get_playlist(self.conn)
        self.assertEmpty(should_be_empty)

        self.set_now(date_f)
        [should_be_x] = assets_helper.get_playlist(self.conn)
        self.assertEqual(asset_x['asset_id'], should_be_x['asset_id'])

        self.set_now(date_g)
        should_be_y_x = assets_helper.get_playlist(self.conn)
        self.assertEqual([should_be_y_x[0]['asset_id'],
                          should_be_y_x[1]['asset_id']],
                         [asset_y['asset_id'],
                          asset_x['asset_id']])

        self.set_now(date_h)
        [should_be_y] = assets_helper.get_playlist(self.conn)
        self.assertEqual(asset_y['asset_id'], should_be_y['asset_id'])
示例#9
0
 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)
示例#10
0
def add_asset():
    asset = prepare_asset(request)
    if url_fails(asset['uri']):
        raise Exception("Could not retrieve file. Check the asset URL.")
    return assets_helper.create(db_conn, asset)
示例#11
0
def add_asset():
    asset = prepare_asset(request)
    if url_fails(asset['uri']):
        raise Exception("Could not retrieve file. Check the asset URL.")
    return assets_helper.create(db_conn, asset)
示例#12
0
 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)
示例#13
0
def add_asset():
    asset = prepare_asset(request)
    #vince temporary change to allow webpages before improving url_fails to manage proxies
    #if url_fails(asset['uri']):
    #    raise Exception("Could not retrieve file. Check the asset URL.")
    return assets_helper.create(db_conn, asset)