'Testing whether a playlist is correctly modified'

@deferred(timeout=10)
def test_edit_playlist(self):

    mock_channel_community = MockObject()
    mock_channel_community.called_modify = False
    my_channel_id = self.create_fake_channel('channel', '')
    def verify_playlist_modified(_):
        self.assertTrue(mock_channel_community.called_modify)
    def modify_playlist_called(playlist_id, modifications):
        self.assertEqual(playlist_id, 1)
        self.assertEqual(modifications['name'], 'test')
        self.assertEqual(modifications['description'], 'test')
        mock_channel_community.called_modify = True
    mock_channel_community.modifyPlaylist = modify_playlist_called
    mock_dispersy = MockObject()
    mock_dispersy.get_community = (lambda _: mock_channel_community)
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    self.create_playlist(my_channel_id, 1234, 42, 'test    playlist', 'test    description')
    post_params = {'name': 'test', 'description': 'test'}
    return self.do_request(('channels/discovered/%s/playlists/1' % 'fakedispersyid'.encode('hex')), expected_code=200, expected_json={'modified': True}, post_data=post_params, request_type='POST').addCallback(verify_playlist_modified)
