Ejemplo n.º 1
0
    def _cs_request(self, url, method, **kwargs):
        # Check that certain things are called correctly
        if method in ["GET", "DELETE"]:
            assert_not_in("body", kwargs)
        elif method in ["PUT", "POST"]:
            assert_in("body", kwargs)

        # Call the method
        munged_url = url.strip("/").replace("/", "_").replace(".", "_")
        callback = "%s_%s" % (method.lower(), munged_url)
        if not hasattr(self, callback):
            fail("Called unknown API method: %s %s" % (method, url))

        # Note the call
        self.callstack.append((method, url, kwargs.get("body", None)))

        status, body = getattr(self, callback)(**kwargs)
        return httplib2.Response({"status": status}), body
Ejemplo n.º 2
0
    def _cs_request(self, url, method, **kwargs):
        # Check that certain things are called correctly
        if method in ['GET', 'DELETE']:
            assert_not_in('body', kwargs)
        elif method in ['PUT', 'POST']:
            assert_in('body', kwargs)

        # Call the method
        munged_url = url.strip('/').replace('/', '_').replace('.', '_')
        callback = "%s_%s" % (method.lower(), munged_url)
        if not hasattr(self, callback):
            fail('Called unknown API method: %s %s' % (method, url))

        # Note the call
        self.callstack.append((method, url, kwargs.get('body', None)))

        status, body = getattr(self, callback)(**kwargs)
        return httplib2.Response({"status": status}), body
Ejemplo n.º 3
0
    def _cs_request(self, url, method, **kwargs):
        # Check that certain things are called correctly
        if method in ['GET', 'DELETE']:
            assert_not_in('body', kwargs)
        elif method in ['PUT', 'POST']:
            assert_in('body', kwargs)

        # Call the method
        munged_url = url.strip('/').replace('/', '_').replace('.', '_')
        callback = "%s_%s" % (method.lower(), munged_url)
        if not hasattr(self, callback):
            fail('Called unknown API method: %s %s' % (method, url))

        # Note the call
        self.callstack.append((method, url, kwargs.get('body', None)))

        status, body = getattr(self, callback)(**kwargs)
        return httplib2.Response({"status": status}), body