예제 #1
0
    def test_create_request_method_is_called(self, patched_verify_request):
        """
        ...then the verify_request() should also be invoked with the
        correct arguments
        """
        expert_client = ExpertAiClient()
        expert_client.create_request(
            endpoint_path="resource_urlpath",
            params={"language": "en"},
            body={"text": "text"},
        )

        patched_verify_request.assert_called_with(
            "resource_urlpath", params={"language": "en"},
        )
예제 #2
0
    def test_a_request_is_created(self, patched_get_method_name_for_endpoint):
        """
        ...then the proper HTTP method should be set
        """

        def fake_get_method(self):
            return {url: "GET"}.get(url)

        url = self.endpoint_path
        expert_client = ExpertAiClient()
        patched_get_method_name_for_endpoint.side_effect = fake_get_method
        new_request = expert_client.create_request(self.endpoint_path)

        self.assertEqual(new_request.string_method, "GET")
        patched_get_method_name_for_endpoint.assert_called_once_with(
            self.endpoint_path
        )