'Test the different "next" actions the comment view can take'

def testCommentNext(self):

    a = Article.objects.get(pk=1)
    data = self.getValidData(a)
    response = self.client.post(u'/post/', data)
    location = response[u'Location']
    match = post_redirect_re.match(location)
    self.assertTrue((match != None), (u'Unexpected    redirect    location:    %s' % location))
    data[u'next'] = u'/somewhere/else/'
    data[u'comment'] = u'This    is    another    comment'
    response = self.client.post(u'/post/', data)
    location = response[u'Location']
    match = re.search(u'^http://testserver/somewhere/else/\\?c=\\d+$', location)
    self.assertTrue((match != None), (u'Unexpected    redirect    location:    %s' % location))
    data[u'next'] = u'http://badserver/somewhere/else/'
    data[u'comment'] = u'This    is    another    comment    with    an    unsafe    next    url'
    response = self.client.post(u'/post/', data)
    location = response[u'Location']
    match = post_redirect_re.match(location)
    self.assertTrue((match != None), (u'Unsafe    redirection    to:    %s' % location))
