How to use the recurly.Response function in recurly

To help you get started, we’ve selected a few recurly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github recurly / recurly-client-python / tests / test_resource.py View on Github external
resp = MagicMock()
        resp.headers = {
            "X-Request-Id": "0av50sm5l2n2gkf88ehg",
            "X-RateLimit-Limit": "2000",
            "X-RateLimit-Remaining": "1985",
            "X-RateLimit-Reset": "1564624560",
            "Date": "Thu, 01 Aug 2019 01:26:44 GMT",
            "Server": "cloudflare",
            "CF-RAY": "4ff4b71268424738-EWR",
        }

        request = Request("GET", "/sites", {})
        empty = cast({}, "Empty", Response(resp, request))
        response = empty.get_response()

        self.assertEqual(type(response), Response)
        self.assertEqual(response.request_id, "0av50sm5l2n2gkf88ehg")
        self.assertEqual(response.rate_limit, 2000)
        self.assertEqual(response.rate_limit_remaining, 1985)
        self.assertEqual(response.rate_limit_reset, datetime(2019, 8, 1, 1, 56))
        self.assertEqual(response.date, "Thu, 01 Aug 2019 01:26:44 GMT")
        self.assertEqual(response.proxy_metadata["server"], "cloudflare")
        self.assertEqual(response.proxy_metadata["cf-ray"], "4ff4b71268424738-EWR")
        self.assertEqual(response.request.method, "GET")
        self.assertEqual(response.request.path, "/sites")
        self.assertEqual(response.request.body, {})

        resp = MagicMock()
        resp.headers = {
            "X-Request-Id": "abcd123",
            "X-RateLimit-Limit": "invalid2000",
            "X-RateLimit-Remaining": "1985",
github recurly / recurly-client-python / tests / test_resource.py View on Github external
self.assertEqual(response.proxy_metadata["cf-ray"], "4ff4b71268424738-EWR")
        self.assertEqual(response.request.method, "GET")
        self.assertEqual(response.request.path, "/sites")
        self.assertEqual(response.request.body, {})

        resp = MagicMock()
        resp.headers = {
            "X-Request-Id": "abcd123",
            "X-RateLimit-Limit": "invalid2000",
            "X-RateLimit-Remaining": "1985",
            "X-RateLimit-Reset": "1564624560",
            "Date": "Thu, 01 Aug 2019 01:26:44 GMT",
        }

        with self.assertRaises(ValueError):
            cast({}, "Empty", Response(resp, request))
github recurly / recurly-client-python / tests / test_resource.py View on Github external
def test_cast_from_response(self):
        resp = MagicMock()
        resp.headers = {
            "X-Request-Id": "0av50sm5l2n2gkf88ehg",
            "X-RateLimit-Limit": "2000",
            "X-RateLimit-Remaining": "1985",
            "X-RateLimit-Reset": "1564624560",
            "Date": "Thu, 01 Aug 2019 01:26:44 GMT",
            "Server": "cloudflare",
            "CF-RAY": "4ff4b71268424738-EWR",
        }

        request = Request("GET", "/sites", {})
        empty = cast({}, "Empty", Response(resp, request))
        response = empty.get_response()

        self.assertEqual(type(response), Response)
        self.assertEqual(response.request_id, "0av50sm5l2n2gkf88ehg")
        self.assertEqual(response.rate_limit, 2000)
        self.assertEqual(response.rate_limit_remaining, 1985)
        self.assertEqual(response.rate_limit_reset, datetime(2019, 8, 1, 1, 56))
        self.assertEqual(response.date, "Thu, 01 Aug 2019 01:26:44 GMT")
        self.assertEqual(response.proxy_metadata["server"], "cloudflare")
        self.assertEqual(response.proxy_metadata["cf-ray"], "4ff4b71268424738-EWR")
        self.assertEqual(response.request.method, "GET")
        self.assertEqual(response.request.path, "/sites")
        self.assertEqual(response.request.body, {})

        resp = MagicMock()
        resp.headers = {