'If no L{Location} header field is found when getting a redirect,
L{client.RedirectAgent} fails with a L{ResponseFailed} error wrapping a
L{error.RedirectWithNoLocation} exception.'

def test_noLocationField(self):

    deferred = self.agent.request('GET', 'http://example.com/foo')
    (req, res) = self.protocol.requests.pop()
    headers = http_headers.Headers()
    response = Response(('HTTP', 1, 1), 301, 'OK', headers, None)
    res.callback(response)
    fail = self.failureResultOf(deferred, client.ResponseFailed)
    fail.value.reasons[0].trap(error.RedirectWithNoLocation)
    self.assertEqual('http://example.com/foo', fail.value.reasons[0].value.uri)
    self.assertEqual(301, fail.value.response.code)
