def setUp(self):
     yield super(TimestampCheckerTestCase, self).setUp()
     self.ws = MockWebServer()
     self.ws.start()
     self.addCleanup(self.ws.stop)
     self.webclient_class = webclient_module().WebClient
     self.patch(timestamp.TimestampChecker, "SERVER_IRI", self.ws.get_iri())
    def setUp(self):
        """Set the diff tests."""
        yield super(SSLTestCase, self).setUp()

        self.memento = MementoHandler()
        self.memento.setLevel(logging.DEBUG)
        logger = webclient.webclient_module().logger
        logger.addHandler(self.memento)
        self.addCleanup(logger.removeHandler, self.memento)

        self.wc = webclient.webclient_factory()
        self.addCleanup(self.wc.shutdown)

        self.called = []
 def test_webclient_module_libsoup(self):
     """Test the module name for the libsoup case."""
     module = webclient.webclient_module()
     self.assert_module_name(module, "libsoup")
SAMPLE_HEADERS = {SAMPLE_KEY: SAMPLE_VALUE}
SAMPLE_POST_PARAMS = {"param1": "value1", "param2": "value2"}
SAMPLE_JPEG_HEADER = '\xff\xd8\xff\xe0\x00\x10JFIF'

SIMPLERESOURCE = "simpleresource"
BYTEZERORESOURCE = "bytezeroresource"
POSTABLERESOURCE = "postableresource"
THROWERROR = "throwerror"
UNAUTHORIZED = "unauthorized"
HEADONLY = "headonly"
VERIFYHEADERS = "verifyheaders"
VERIFYPOSTPARAMS = "verifypostparams"
GUARDED = "guarded"
AUTHRESOURCE = "authresource"

WEBCLIENT_MODULE_NAME = webclient.webclient_module().__name__


def sample_get_credentials():
    """Will return the sample credentials right now."""
    return defer.succeed(SAMPLE_CREDENTIALS)


class SimpleResource(resource.Resource):
    """A simple web resource."""

    def render_GET(self, request):
        """Make a bit of html out of these resource's content."""
        return SAMPLE_RESOURCE