##// END OF EJS Templates
fix(svn): fixed problems with svn hooks binary dir not beeing propagates in mod_dav_svn
fix(svn): fixed problems with svn hooks binary dir not beeing propagates in mod_dav_svn

File last commit:

r1152:a0c49580 default
r1229:fe30068d v5.0.1 stable
Show More
test_lib.py
142 lines | 4.7 KiB | text/x-python | PythonLexer
git-lfs: added vcsserver handling of git-lfs objects....
r180 # RhodeCode VCSServer provides access to different vcs backends via network.
source-code: updated copyrights to 2023
r1126 # Copyright (C) 2014-2023 RhodeCode GmbH
git-lfs: added vcsserver handling of git-lfs objects....
r180 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
import os
import pytest
packages: move the str utils to it's own module
r1060 from vcsserver.str_utils import safe_bytes
git-lfs: added vcsserver handling of git-lfs objects....
r180 from vcsserver.git_lfs.lib import OidHandler, LFSOidStore
@pytest.fixture()
def lfs_store(tmpdir):
repo = 'test'
oid = '123456789'
git-lfs: don't store oid under repo-path....
r181 store = LFSOidStore(oid=oid, repo=repo, store_location=str(tmpdir))
git-lfs: added vcsserver handling of git-lfs objects....
r180 return store
@pytest.fixture()
def oid_handler(lfs_store):
store = lfs_store
repo = store.repo
oid = store.oid
oid_handler = OidHandler(
store=store, repo_name=repo, auth=('basic', 'xxxx'),
oid=oid,
obj_size='1024', obj_data={}, obj_href='http://localhost/handle_oid',
obj_verify_href='http://localhost/verify')
return oid_handler
lint: auto-fixes
r1152 class TestOidHandler:
git-lfs: added vcsserver handling of git-lfs objects....
r180
@pytest.mark.parametrize('exec_action', [
'download',
'upload',
])
def test_exec_action(self, exec_action, oid_handler):
handler = oid_handler.exec_operation(exec_action)
assert handler
def test_exec_action_undefined(self, oid_handler):
with pytest.raises(AttributeError):
oid_handler.exec_operation('wrong')
def test_download_oid_not_existing(self, oid_handler):
response, has_errors = oid_handler.exec_operation('download')
assert response is None
assert has_errors['error'] == {
'code': 404,
'message': 'object: 123456789 does not exist in store'}
def test_download_oid(self, oid_handler):
store = oid_handler.get_store()
git-lfs: don't store oid under repo-path....
r181 if not os.path.isdir(os.path.dirname(store.oid_path)):
os.makedirs(os.path.dirname(store.oid_path))
git-lfs: added vcsserver handling of git-lfs objects....
r180
with open(store.oid_path, 'wb') as f:
python3: code change for py3 support...
r1048 f.write(safe_bytes('CONTENT'))
git-lfs: added vcsserver handling of git-lfs objects....
r180
response, has_errors = oid_handler.exec_operation('download')
assert has_errors is None
assert response['download'] == {
'header': {'Authorization': 'basic xxxx'},
'href': 'http://localhost/handle_oid'
}
def test_upload_oid_that_exists(self, oid_handler):
store = oid_handler.get_store()
git-lfs: don't store oid under repo-path....
r181 if not os.path.isdir(os.path.dirname(store.oid_path)):
os.makedirs(os.path.dirname(store.oid_path))
git-lfs: added vcsserver handling of git-lfs objects....
r180
with open(store.oid_path, 'wb') as f:
python3: code change for py3 support...
r1048 f.write(safe_bytes('CONTENT'))
git-lfs: fixed tests for upload, and added new for file verification.
r201 oid_handler.obj_size = 7
git-lfs: added vcsserver handling of git-lfs objects....
r180 response, has_errors = oid_handler.exec_operation('upload')
assert has_errors is None
assert response is None
git-lfs: fixed tests for upload, and added new for file verification.
r201 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:
python3: code change for py3 support...
r1048 f.write(safe_bytes('CONTENT'))
git-lfs: fixed tests for upload, and added new for file verification.
r201
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',
}
git-lfs: added vcsserver handling of git-lfs objects....
r180 def test_upload_oid(self, oid_handler):
response, has_errors = oid_handler.exec_operation('upload')
assert has_errors is None
assert response['upload'] == {
git-lfs: fixed tests for upload, and added new for file verification.
r201 'header': {'Authorization': 'basic xxxx',
'Transfer-Encoding': 'chunked'},
git-lfs: added vcsserver handling of git-lfs objects....
r180 'href': 'http://localhost/handle_oid'
}
lint: auto-fixes
r1152 class TestLFSStore:
git-lfs: added vcsserver handling of git-lfs objects....
r180 def test_write_oid(self, lfs_store):
oid_location = lfs_store.oid_path
assert not os.path.isfile(oid_location)
engine = lfs_store.get_engine(mode='wb')
with engine as f:
python3: code change for py3 support...
r1048 f.write(safe_bytes('CONTENT'))
git-lfs: added vcsserver handling of git-lfs objects....
r180
assert os.path.isfile(oid_location)
def test_detect_has_oid(self, lfs_store):
assert lfs_store.has_oid() is False
engine = lfs_store.get_engine(mode='wb')
with engine as f:
python3: code change for py3 support...
r1048 f.write(safe_bytes('CONTENT'))
git-lfs: added vcsserver handling of git-lfs objects....
r180
python3: code change for py3 support...
r1048 assert lfs_store.has_oid() is True