blob: 838df710e3e6e842684e5549de9feb05992269a4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import os
import pytest
from unittest.mock import Mock
from g2h.file import sanitize_file_name, tree_join
def test_sanitize_not_necessary():
assert(sanitize_file_name('foo', None) == 'foo')
def test_sanitize_success():
assert(sanitize_file_name('.test', []) == '_test')
def test_sanitize_collissions():
entries = []
for i in range(1, 10):
entry = Mock()
entry.name = '_' * i + 'test'
entries.append(entry)
with pytest.raises(RuntimeError):
sanitize_file_name('.test', entries)
def test_tree_join():
commit = Mock()
commit.hexsha = '123'
assert(tree_join(commit, 'test') == os.path.join('123', 't', 'test'))
|