##// END OF EJS Templates
fix(server-info): removed dulwich from update-server-info logic, and added force-flag feature
fix(server-info): removed dulwich from update-server-info logic, and added force-flag feature

File last commit:

r1196:b009ad36 default
r1197:bad64234 default
Show More
test_utils.py
69 lines | 2.0 KiB | text/x-python | PythonLexer
python3: code change for py3 support...
r1048 # RhodeCode VCSServer provides access to different vcs backends via network.
source-code: updated copyrights to 2023
r1126 # Copyright (C) 2014-2023 RhodeCode GmbH
python3: code change for py3 support...
r1048 #
# 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 pytest
fix(auth-info): fixed auth credentials problem for HG Fixes RCCE-33...
r1196 from vcsserver.str_utils import ascii_bytes, ascii_str, convert_to_str
python3: code change for py3 support...
r1048
@pytest.mark.parametrize('given, expected', [
('a', b'a'),
python3: another 2to3 pass
r1054 ('a', b'a'),
python3: code change for py3 support...
r1048 ])
def test_ascii_bytes(given, expected):
assert ascii_bytes(given) == expected
@pytest.mark.parametrize('given', [
'å',
'å'.encode('utf8')
])
def test_ascii_bytes_raises(given):
with pytest.raises(ValueError):
ascii_bytes(given)
@pytest.mark.parametrize('given, expected', [
(b'a', 'a'),
])
def test_ascii_str(given, expected):
assert ascii_str(given) == expected
@pytest.mark.parametrize('given', [
python3: another 2to3 pass
r1054 'a',
python3: code change for py3 support...
r1048 'å'.encode('utf8'),
python3: another 2to3 pass
r1054 'å'
python3: code change for py3 support...
r1048 ])
def test_ascii_str_raises(given):
with pytest.raises(ValueError):
ascii_str(given)
fix(auth-info): fixed auth credentials problem for HG Fixes RCCE-33...
r1196
@pytest.mark.parametrize('given, expected', [
('a', 'a'),
(b'a', 'a'),
# tuple
(('a', b'b', b'c'), ('a', 'b', 'c')),
# nested tuple
(('a', b'b', (b'd', b'e')), ('a', 'b', ('d', 'e'))),
# list
(['a', b'b', b'c'], ['a', 'b', 'c']),
# mixed
(['a', b'b', b'c', (b'b1', b'b2')], ['a', 'b', 'c', ('b1', 'b2')])
])
def test_convert_to_str(given, expected):
assert convert_to_str(given) == expected