def test_overwrite_file(self): client = BoxClient("my_token") (flexmock(client).should_receive("_check_for_errors").once()) expected_headers = {"If-Match": "some_tag"} expected_headers.update(client.default_headers) expected_response = mocked_response({"entries": [{"id": "1"}]}) ( flexmock(requests) .should_receive("post") .with_args( "https://upload.box.com/api/2.0/files/666/content", {"content_modified_at": "2006-05-04T03:02:01+00:00"}, headers=expected_headers, files={"file": FileObjMatcher("hello world")}, ) .and_return(expected_response) .once() ) result = client.overwrite_file( 666, StringIO("hello world"), etag="some_tag", content_modified_at=datetime(2006, 5, 4, 3, 2, 1, 0, tzinfo=UTC()), ) self.assertEqual({"id": "1"}, result)
def test_overwrite_file(self): client = BoxClient('my_token') (flexmock(client) .should_receive('_check_for_errors') .once()) expected_headers = { 'If-Match': 'some_tag' } expected_headers.update(client.default_headers) expected_response = mocked_response({'entries': [{'id': '1'}]}) (flexmock(requests) .should_receive('post') .with_args('https://upload.box.com/api/2.0/files/666/content', {'content_modified_at': '2006-05-04T03:02:01+00:00'}, headers=expected_headers, files={'file': FileObjMatcher('hello world')}) .and_return(expected_response) .once()) result = client.overwrite_file(666, StringIO('hello world'), etag='some_tag', content_modified_at=datetime(2006, 5, 4, 3, 2, 1, 0, tzinfo=UTC()),) self.assertEqual({'id': '1'}, result)