Ejemplo n.º 1
0
def add_channel(name, uuid):
    '''add new channel, return channel obj'''
    channel = ChannelStorage()
    channel.name = name
    channel.uuid = uuid
    channel.upload_date = datetime.datetime.now()
    channel.save()
    return channel
Ejemplo n.º 2
0
 def test_update(self):
     assert len(ChannelStorage.get()) == 0
     channel = ChannelStorage()
     channel.name = 'demo_name'
     channel.music_list = ['1' * 24]
     now = datetime.datetime(2013, 12, 24, 10, 8, 3)
     channel.upload_date = now
     channel.uuid = 'douban-cid'
     channel.save()
     channel.update(music_list=['2' * 24])
     channel = ChannelStorage.get()[0]
     assert channel.music_list == ['2' * 24]
Ejemplo n.º 3
0
 def test_simple(self):
     assert len(ChannelStorage.get()) == 0
     channel = ChannelStorage()
     channel.name = 'demo_name'
     channel.music_list = ['1' * 24]
     now = datetime.datetime(2013, 12, 24, 10, 8, 3)
     channel.upload_date = now
     channel.uuid = 'douban-cid'
     channel.save()
     assert len(ChannelStorage.get()) == 1
     assert len(ChannelStorage.get(name='demo_name')) == 1
     assert len(ChannelStorage.get(name='unkown')) == 0
     channel = ChannelStorage.get()[0]
     assert channel.name == 'demo_name'
     assert channel.music_list == ['1' * 24]
     assert channel.upload_date == now
     channel.delete()
     assert len(ChannelStorage.get()) == 0