コード例 #1
0
    def test_cached(self):
        """The function should return all the data, but should not query the API twice."""
        # Setup the mocked response, refrain from matching the query string
        responses.add(responses.GET, self.api_url, json=self.valid_response,
                      status=200, match_querystring=False)

        acme = ACMEAccount(client=self.client)
        acme.all(self.org_id)
        data = acme.all(self.org_id)

        # Verify all the query information
        # There should only be one call the first time "all" is called.
        # Due to pagination, this is only guaranteed as long as the number of
        # entries returned is less than the page size
        self.assertEqual(len(responses.calls), 1)
        self.match_url_with_qs(responses.calls[0].request.url)
        self.assertEqual(data, self.valid_response)
コード例 #2
0
    def test_init_param(self):
        """The URL should change if api_version is passed as a parameter to
        class initialization."""
        # Set a new version
        version = "v3"
        api_url = self.get_api_url(api_version=version)

        # Setup the mocked response
        responses.add(responses.GET, api_url, json=self.valid_response,
                      status=200, match_querystring=False)

        acme = ACMEAccount(client=self.client, api_version=version)
        data = acme.all(self.org_id)

        # Verify all the query information
        # There should only be one call the first time "all" is called.
        # Due to pagination, this is only guaranteed as long as the number of
        # entries returned is less than the page size
        self.assertEqual(len(responses.calls), 1)
        self.match_url_with_qs(responses.calls[0].request.url, api_url=api_url)
        self.assertEqual(data, self.valid_response)