def test_post_dict(self): client = BoxClient('my_token') expected_data = {'arg': 'value'} expected_response = self.make_response() flexmock(requests) \ .should_receive('post') \ .with_args('https://api.box.com/2.0/foo', CallableMatcher(lambda x: json.loads(x) == expected_data), headers=client._headers, crap=1) \ .and_return(expected_response) \ .once() actual_response = client._post('foo', expected_data, crap=1) self.assertEqual(expected_response, actual_response)
def test_post_data(self): client = BoxClient('my_token') expected_data = 'mooooo' expected_response = self.make_response() flexmock(requests) \ .should_receive('post') \ .with_args('https://api.box.com/2.0/foo', expected_data, headers=client._headers, crap=1) \ .and_return(expected_response) \ .once() actual_response = client._post('foo', expected_data, crap=1) self.assertEqual(expected_response, actual_response)