tests: fixed scm tests
This commit is contained in:
parent
8235aaf181
commit
f3a9d5faea
1 changed files with 14 additions and 13 deletions
|
|
@ -126,8 +126,8 @@ def test_get_nodes_returns_unicode_flat(backend):
|
|||
repo = backend.repo
|
||||
commit_id = repo.get_commit(commit_idx=0).raw_id
|
||||
directories, files = scm.ScmModel().get_nodes(repo.repo_name, commit_id, flat=True)
|
||||
assert_contains_only_unicode(directories)
|
||||
assert_contains_only_unicode(files)
|
||||
assert_contains_only_str_chars(directories)
|
||||
assert_contains_only_str_chars(files)
|
||||
|
||||
|
||||
def test_get_nodes_returns_unicode_non_flat(backend):
|
||||
|
|
@ -137,8 +137,8 @@ def test_get_nodes_returns_unicode_non_flat(backend):
|
|||
directories, files = scm.ScmModel().get_nodes(repo.repo_name, commit_id, flat=False)
|
||||
# johbo: Checking only the names for now, since that is the critical
|
||||
# part.
|
||||
assert_contains_only_unicode([d['name'] for d in directories])
|
||||
assert_contains_only_unicode([f['name'] for f in files])
|
||||
assert_contains_only_str_chars([d['name'] for d in directories])
|
||||
assert_contains_only_str_chars([f['name'] for f in files])
|
||||
|
||||
|
||||
def test_get_nodes_max_file_bytes(backend_random):
|
||||
|
|
@ -158,31 +158,32 @@ def test_get_nodes_max_file_bytes(backend_random):
|
|||
for file in files)
|
||||
|
||||
|
||||
def assert_contains_only_unicode(structure):
|
||||
def assert_contains_only_str_chars(structure):
|
||||
assert structure
|
||||
for value in structure:
|
||||
assert isinstance(value, str)
|
||||
|
||||
|
||||
@pytest.mark.backends("hg", "git")
|
||||
def test_get_non_unicode_reference(backend):
|
||||
def test_get_non_str_reference(backend):
|
||||
model = scm.ScmModel()
|
||||
non_unicode_list = ["Adını".encode("cp1254")]
|
||||
special_name = "Adını"
|
||||
non_str_list = [special_name]
|
||||
|
||||
def scm_instance():
|
||||
return Mock(
|
||||
branches=non_unicode_list, bookmarks=non_unicode_list,
|
||||
tags=non_unicode_list, alias=backend.alias)
|
||||
branches=non_str_list, bookmarks=non_str_list,
|
||||
tags=non_str_list, alias=backend.alias)
|
||||
|
||||
repo = Mock(__class__=db.Repository, scm_instance=scm_instance)
|
||||
choices, __ = model.get_repo_landing_revs(translator=lambda s: s, repo=repo)
|
||||
if backend.alias == 'hg':
|
||||
valid_choices = [
|
||||
'rev:tip', 'branch:Ad\xc4\xb1n\xc4\xb1',
|
||||
'book:Ad\xc4\xb1n\xc4\xb1', 'tag:Ad\xc4\xb1n\xc4\xb1']
|
||||
'rev:tip', f'branch:{special_name}',
|
||||
f'book:{special_name}', f'tag:{special_name}']
|
||||
else:
|
||||
valid_choices = [
|
||||
'rev:tip', 'branch:Ad\xc4\xb1n\xc4\xb1',
|
||||
'tag:Ad\xc4\xb1n\xc4\xb1']
|
||||
'rev:tip', f'branch:{special_name}',
|
||||
f'tag:{special_name}']
|
||||
|
||||
assert choices == valid_choices
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue