aboutsummaryrefslogtreecommitdiffstats
path: root/tests/packager/test_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/packager/test_utils.py')
-rw-r--r--tests/packager/test_utils.py68
1 files changed, 67 insertions, 1 deletions
diff --git a/tests/packager/test_utils.py b/tests/packager/test_utils.py
index 7456302..450a526 100644
--- a/tests/packager/test_utils.py
+++ b/tests/packager/test_utils.py
@@ -62,4 +62,70 @@ def test_verify_bad(tmpdir):
with pytest.raises(subprocess.CalledProcessError):
utils.verify(str(p), CERT_FILE, cms, no_verify_cert=True)
-
+
+
+CHECK_FILE_CASES = [
+ {
+ 'negative': False,
+ 'params': {'root': RESOURCES_DIR,
+ 'entry': 'test.key',
+ 'msg': '',
+ 'check_for_non': False,
+ 'check_dir': False,
+ }
+ },
+ {
+ 'negative': False,
+ 'params': {'root': RESOURCES_DIR,
+ 'entry': 'non-existing-file',
+ 'msg': '',
+ 'check_for_non': True,
+ 'check_dir': False,
+ }
+ },
+ {
+ 'negative': True,
+ 'params': {'root': RESOURCES_DIR,
+ 'entry': 'non-existing-file',
+ 'msg': '',
+ 'check_for_non': False,
+ 'check_dir': False,
+ }
+ },
+ {
+ 'negative': False,
+ 'params': {'root': ROOT_DIR,
+ 'entry': 'tests',
+ 'msg': '',
+ 'check_for_non': False,
+ 'check_dir': True,
+ }
+ },
+ {
+ 'negative': False,
+ 'params': {'root': ROOT_DIR,
+ 'entry': 'non-existing-dir',
+ 'msg': '',
+ 'check_for_non': True,
+ 'check_dir': True,
+ }
+ },
+ {
+ 'negative': True,
+ 'params': {'root': ROOT_DIR,
+ 'entry': 'non-existing-dir',
+ 'msg': '',
+ 'check_for_non': False,
+ 'check_dir': True,
+ }
+ },
+ ]
+
+
+def test_check_file_dir():
+ for case in CHECK_FILE_CASES:
+ if case['negative']:
+ with pytest.raises(ValueError):
+ utils.check_file_dir(**case['params'])
+ else:
+ utils.check_file_dir(**case['params'])