Exemplo n.º 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_)
Exemplo n.º 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_)
Exemplo n.º 3
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_)
Exemplo n.º 4
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_)
Exemplo n.º 5
0
    def patch(self, asset_id):
        data = json.loads(request.data)
        with db.conn(settings['database']) as conn:

            asset = assets_helper.read(conn, asset_id)
            if not asset:
                raise Exception('Asset not found.')
            update_asset(asset, data)

            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)
Exemplo n.º 6
0
    def test_update_asset(self):
        asset_x_ = assets_helper.create(self.conn, asset_x)
        asset_x_copy = asset_x_.copy()
        data = {
            'name': 'New name',
            'mimetype': 'should not setted',
            'empty': 'non exists field'
        }

        self.assertEquals(asset_x_, asset_x_copy)

        server.update_asset(asset_x_copy, data)
        asset_x_copy = assets_helper.update(self.conn, asset_x_copy.get('id'),
                                            asset_x_copy)

        self.assertEquals(
            asset_x_copy, {
                'is_enabled': 1,
                'asset_id': None,
                'end_date': datetime.datetime(2013, 1, 19, 23, 59),
                'is_active': 0,
                'duration': u'5',
                'mimetype': u'web',
                'name': 'New name',
                'uri': u'http://www.wireload.net',
                'play_order': 1,
                'start_date': datetime.datetime(2013, 1, 16, 0, 0)
            })

        self.assertNotEqual(asset_x_, asset_x_copy)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
 def put(self, asset_id):
     with db.conn(settings['database']) as conn:
         return assets_helper.update(conn, asset_id, prepare_asset(request))
Exemplo n.º 10
0
 def put(self, asset_id):
     with db.conn(settings['database']) as conn:
         return assets_helper.update(conn, asset_id, prepare_asset(request))
Exemplo n.º 11
0
def edit_asset(asset_id):
    return assets_helper.update(db_conn, asset_id, prepare_asset(request))
Exemplo n.º 12
0
def edit_asset(asset_id):
    return assets_helper.update(db_conn, asset_id, prepare_asset(request))