Skip to content

Instantly share code, notes, and snippets.

@jerith
Created January 13, 2016 11:20
Show Gist options
  • Select an option

  • Save jerith/b72b06993cbd451ab282 to your computer and use it in GitHub Desktop.

Select an option

Save jerith/b72b06993cbd451ab282 to your computer and use it in GitHub Desktop.
from twisted.trial import unittest
from twisted.test import proto_helpers
from vumi_http_proxy.http_proxy import ProxyFactory
class CheckProxyRequestTestCase(unittest.TestCase):
def test_process(self):
factory = ProxyFactory()
proto = factory.buildProtocol(('0.0.0.0', 0))
tr = proto_helpers.StringTransport()
proto.makeConnection(tr)
proto.dataReceived("\r\n".join([
"GET http://zombo.com/ HTTP/1.1",
"Host: zombo.com",
"",
"",
]))
self.assertEqual(tr.value(), "\r\n".join([
"HTTP/1.1 200 OK",
"Transfer-Encoding: chunked",
"",
"13",
"<html>Denied</html>",
"0",
"",
"",
]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment