# HG changeset patch # User Marcin Kuzminski # Date 2017-04-18 07:53:45 # Node ID 57b77f295addd7614a907f1ef4064e65f9d9abea # Parent 2f375119838c0fa7ca6fbd723d523945e073ecf3 git-lfs: fixed tests for upload, and added new for file verification. diff --git a/vcsserver/git_lfs/lib.py b/vcsserver/git_lfs/lib.py --- a/vcsserver/git_lfs/lib.py +++ b/vcsserver/git_lfs/lib.py @@ -81,9 +81,12 @@ class OidHandler(object): log.debug('LFS: store already has oid %s', store.oid) # validate size - size_match = store.size_oid() == self.obj_size + store_size = store.size_oid() + size_match = store_size == self.obj_size if not size_match: - log.warning('LFS: size mismatch for oid:%s', self.oid) + log.warning( + 'LFS: size mismatch for oid:%s, in store:%s expected: %s', + self.oid, store_size, self.obj_size) elif skip_existing: log.debug('LFS: skipping further action as oid is existing') return response, has_errors diff --git a/vcsserver/git_lfs/tests/test_lib.py b/vcsserver/git_lfs/tests/test_lib.py --- a/vcsserver/git_lfs/tests/test_lib.py +++ b/vcsserver/git_lfs/tests/test_lib.py @@ -87,16 +87,34 @@ class TestOidHandler(object): with open(store.oid_path, 'wb') as f: f.write('CONTENT') - + oid_handler.obj_size = 7 response, has_errors = oid_handler.exec_operation('upload') assert has_errors is None assert response is None + def test_upload_oid_that_exists_but_has_wrong_size(self, oid_handler): + store = oid_handler.get_store() + if not os.path.isdir(os.path.dirname(store.oid_path)): + os.makedirs(os.path.dirname(store.oid_path)) + + with open(store.oid_path, 'wb') as f: + f.write('CONTENT') + + oid_handler.obj_size = 10240 + response, has_errors = oid_handler.exec_operation('upload') + assert has_errors is None + assert response['upload'] == { + 'header': {'Authorization': 'basic xxxx', + 'Transfer-Encoding': 'chunked'}, + 'href': 'http://localhost/handle_oid', + } + def test_upload_oid(self, oid_handler): response, has_errors = oid_handler.exec_operation('upload') assert has_errors is None assert response['upload'] == { - 'header': {'Authorization': 'basic xxxx'}, + 'header': {'Authorization': 'basic xxxx', + 'Transfer-Encoding': 'chunked'}, 'href': 'http://localhost/handle_oid' }