Example #1
0
    def test_put_data(self):
        client = BoxClient('my_token')

        expected_data = 'mooooo'
        expected_response = self.make_response()
        flexmock(requests) \
            .should_receive('put') \
            .with_args('https://api.box.com/2.0/foo',
                       expected_data,
                       headers=client._headers,
                       crap=1) \
            .and_return(expected_response) \
            .once()

        actual_response = client._put('foo', expected_data, crap=1)
        self.assertEqual(expected_response, actual_response)
Example #2
0
    def test_put_dict(self):
        client = BoxClient('my_token')

        expected_data = {'arg': 'value'}
        expected_response = self.make_response()
        flexmock(requests) \
            .should_receive('put') \
            .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._put('foo', expected_data, crap=1)
        self.assertEqual(expected_response, actual_response)