'L{CookieAgent.request} does not insert any C{\'Cookie\'} header into the
L{Request} object if there is no cookie in the cookie jar for the URI
being requested. Cookies are extracted from the response and stored in
the cookie jar.'

def test_emptyCookieJarRequest(self):

    cookieJar = cookielib.CookieJar()
    self.assertEqual(list(cookieJar), [])
    agent = self.buildAgentForWrapperTest(self.reactor)
    cookieAgent = client.CookieAgent(agent, cookieJar)
    d = cookieAgent.request('GET', 'http://example.com:1234/foo?bar')
    def _checkCookie(ignored):
        cookies = list(cookieJar)
        self.assertEqual(len(cookies), 1)
        self.assertEqual(cookies[0].name, 'foo')
        self.assertEqual(cookies[0].value, '1')
    d.addCallback(_checkCookie)
    (req, res) = self.protocol.requests.pop()
    self.assertIdentical(req.headers.getRawHeaders('cookie'), None)
    resp = client.Response(('HTTP', 1, 1), 200, 'OK', client.Headers({'Set-Cookie': ['foo=1']}), None)
    res.callback(resp)
    return d
