forked from xenserver/status-report
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dir_list.py
35 lines (28 loc) · 1.11 KB
/
test_dir_list.py
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
27
28
29
30
31
32
33
34
35
"""tests/unit/test_dir_list.py: Unit-Test bugtool.dir_list(cap, path_list)"""
def test_dir_list(bugtool):
"""Test the bugtool function dir_list(cap, path_list) to perform as expected"""
# Arguments for the positive test:
cap = bugtool.CAP_XENSERVER_CONFIG
path_list = [__file__.replace(".", "*")]
# Assert that mismatching cap causes no output in bugtool.data:
bugtool.entries = [bugtool.CAP_DISK_INFO, cap, bugtool.CAP_PAM]
bugtool.dir_list(cap=bugtool.CAP_XENSERVER_LOGS, path_list=path_list)
assert bugtool.data == {}
# Assert that mismatching path_list results in no bugtool.data:
bugtool.dir_list(cap=cap, path_list=[__file__ + "*nonexisting*"])
assert bugtool.data == {}
# Assert matching cap and path_list produces expected_data
bugtool.dir_list(cap=cap, path_list=path_list)
expected_data = {
"ls -l "
+ __file__: {
"filter": None,
"cap": "xenserver-config",
"cmd_args": [
"ls",
"-l",
__file__,
],
}
}
assert bugtool.data == expected_data