diff options
Diffstat (limited to 'tests/file_test.py')
| -rw-r--r-- | tests/file_test.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/file_test.py b/tests/file_test.py new file mode 100644 index 0000000..838df71 --- /dev/null +++ b/tests/file_test.py @@ -0,0 +1,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')) |