##// END OF EJS Templates
git-lfs: fixed tests for upload, and added new for file verification.
marcink -
r207:57b77f29 stable
parent child Browse files
Show More
@@ -81,9 +81,12 b' class OidHandler(object):'
81 log.debug('LFS: store already has oid %s', store.oid)
81 log.debug('LFS: store already has oid %s', store.oid)
82
82
83 # validate size
83 # validate size
84 size_match = store.size_oid() == self.obj_size
84 store_size = store.size_oid()
85 size_match = store_size == self.obj_size
85 if not size_match:
86 if not size_match:
86 log.warning('LFS: size mismatch for oid:%s', self.oid)
87 log.warning(
88 'LFS: size mismatch for oid:%s, in store:%s expected: %s',
89 self.oid, store_size, self.obj_size)
87 elif skip_existing:
90 elif skip_existing:
88 log.debug('LFS: skipping further action as oid is existing')
91 log.debug('LFS: skipping further action as oid is existing')
89 return response, has_errors
92 return response, has_errors
@@ -87,16 +87,34 b' class TestOidHandler(object):'
87
87
88 with open(store.oid_path, 'wb') as f:
88 with open(store.oid_path, 'wb') as f:
89 f.write('CONTENT')
89 f.write('CONTENT')
90
90 oid_handler.obj_size = 7
91 response, has_errors = oid_handler.exec_operation('upload')
91 response, has_errors = oid_handler.exec_operation('upload')
92 assert has_errors is None
92 assert has_errors is None
93 assert response is None
93 assert response is None
94
94
95 def test_upload_oid_that_exists_but_has_wrong_size(self, oid_handler):
96 store = oid_handler.get_store()
97 if not os.path.isdir(os.path.dirname(store.oid_path)):
98 os.makedirs(os.path.dirname(store.oid_path))
99
100 with open(store.oid_path, 'wb') as f:
101 f.write('CONTENT')
102
103 oid_handler.obj_size = 10240
104 response, has_errors = oid_handler.exec_operation('upload')
105 assert has_errors is None
106 assert response['upload'] == {
107 'header': {'Authorization': 'basic xxxx',
108 'Transfer-Encoding': 'chunked'},
109 'href': 'http://localhost/handle_oid',
110 }
111
95 def test_upload_oid(self, oid_handler):
112 def test_upload_oid(self, oid_handler):
96 response, has_errors = oid_handler.exec_operation('upload')
113 response, has_errors = oid_handler.exec_operation('upload')
97 assert has_errors is None
114 assert has_errors is None
98 assert response['upload'] == {
115 assert response['upload'] == {
99 'header': {'Authorization': 'basic xxxx'},
116 'header': {'Authorization': 'basic xxxx',
117 'Transfer-Encoding': 'chunked'},
100 'href': 'http://localhost/handle_oid'
118 'href': 'http://localhost/handle_oid'
101 }
119 }
102
120
General Comments 0
You need to be logged in to leave comments. Login now