コード例 #1
0
    def generic_test(self):
        """Generic test for .find request parameters/response fields"""
        api_params[params_to_api["org_id"]] = str(self.org_id)
        valid_response = [
            entry for entry in self.valid_response
            if all(
                str(entry[k]).lower().find(str(api_params[k]).lower()) != -1
                for k in api_params
            )
        ]
        # Setup the mocked response
        responses.add(
            responses.GET, self.api_url, json=valid_response, status=200, match_querystring=False
        )
        acme = ACMEAccount(client=self.client)
        data = list(acme.find(self.org_id, **params))

        # Verify all the query information
        # There should only be one call when "find" 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_params)
        self.assertEqual(data, valid_response)
コード例 #2
0
 def test_need_org_id(self):
     """The function should raise an exception without an org_id parameter."""
     acme = ACMEAccount(client=self.client)
     # We need to wrap this all crazy because it now returns an iterator
     result = acme.find()  # pylint:disable=no-value-for-parameter
     self.assertRaises(TypeError, result.__next__)