Exemplo n.º 1
0
 def test_process_ubersmith_response_not_application_json(self):
     response = Mock(status_code=200,
                     headers={'content-type': 'text/html'},
                     content='42')
     assert_that(
         response.content,
         equal_to(UbersmithRequest.process_ubersmith_response(response)))
    def __call__(self, **kwargs):
        self._build_request_params(kwargs)

        response = self._process_request(method=requests.get,
                                         url=self.url,
                                         auth=(self.user, self.password),
                                         timeout=self.timeout,
                                         params=kwargs)

        return UbersmithRequest.process_ubersmith_response(response)
    def __call__(self, **kwargs):
        self._build_request_params(kwargs)
        params = _http_utils.form_encode(kwargs)

        response = self._process_request(method=requests.get,
                                         url=self.url,
                                         auth=(self.user, self.password),
                                         timeout=self.timeout,
                                         headers={'user-agent': 'python-ubersmithclient'},
                                         params=params)

        return UbersmithRequest.process_ubersmith_response(response)
    def test_process_ubersmith_response(self):
        response = Mock(status_code=200, headers={'content-type': 'application/json'})

        json_data = {
            'client_id': '1',
            'first': 'Rick',
            'last': 'Sanchez',
            'company': 'Wubba lubba dub dub!'
        }

        response.json = Mock(return_value=a_response_data(data=json_data))

        self.assertDictEqual(json_data, UbersmithRequest.process_ubersmith_response(response))
Exemplo n.º 5
0
    def test_process_ubersmith_response(self):
        response = Mock(status_code=200,
                        headers={'content-type': 'application/json'})

        json_data = {
            'client_id': '1',
            'first': 'Rick',
            'last': 'Sanchez',
            'company': 'Wubba lubba dub dub!'
        }

        response.json = Mock(return_value=a_response_data(data=json_data))

        self.assertDictEqual(
            json_data, UbersmithRequest.process_ubersmith_response(response))
 def test_process_ubersmith_response_not_application_json(self):
     response = Mock(status_code=200, headers={'content-type': 'text/html'}, content='42')
     assert_that(response.content, equal_to(UbersmithRequest.process_ubersmith_response(response)))