'Testing whether the API returns error 404 if the the channel community is missing when creating a new playlist'

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

    self.create_my_channel('my    channel', 'this    is    a    short    description')
    expected_json = {'error': 'description    parameter    missing'}
    post_params = {'name': 'test1', 'description': 'test2'}
    def mocked_get_community(_):
        raise CommunityNotFoundException('abcd')
    mock_dispersy = MockObject()
    mock_dispersy.get_community = mocked_get_community
    self.session.get_dispersy_instance = (lambda : mock_dispersy)
    return self.do_request(('channels/discovered/%s/playlists' % 'fakedispersyid'.encode('hex')), expected_code=404, expected_json=expected_json, post_data=post_params, request_type='PUT')
