'Testing whether the API can create a new playlist in a given channel'

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

    mock_channel_community = MockObject()
    mock_channel_community.called_create = False
    self.create_fake_channel('channel', '')
    def verify_playlist_created(_):
        self.assertTrue(mock_channel_community.called_create)
    def create_playlist_called(name, description, _):
        self.assertEqual(name, 'test1')
        self.assertEqual(description, 'test2')
        mock_channel_community.called_create = True
    mock_channel_community.create_playlist = create_playlist_called
    mock_dispersy = MockObject()
    mock_dispersy.get_community = (lambda _: mock_channel_community)
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    expected_json = {'created': True}
    post_params = {'name': 'test1', 'description': 'test2'}
    return self.do_request(('channels/discovered/%s/playlists' % 'fakedispersyid'.encode('hex')), expected_code=200, expected_json=expected_json, post_data=post_params, request_type='PUT').addCallback(verify_playlist_created)
