-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/unit/test_dir_list.py Test dir_list(cap, path_list) (#32)
Signed-off-by: Bernhard Kaindl <[email protected]>
- Loading branch information
1 parent
adc1fc4
commit 65da321
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
"""tests/unit/test_dir_list.py: Unit-Test bugtool.dir_list(cap, path_list)""" | ||
import sys | ||
import pytest | ||
|
||
|
||
@pytest.mark.skipif(sys.version_info >= (3, 0), reason="dir_list() is not yet py3") | ||
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 mis-matching 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 mis-matching path_list results in no bugtool.data: | ||
bugtool.dir_list(cap=cap, path_list=[__file__ + "*notexist*"]) | ||
assert bugtool.data == {} | ||
|
||
# Assert matching cap and path_list produces expected_data | ||
bugtool.dir_list(cap=cap, path_list=path_list) | ||
|
||
# This assert shows that dir_list() needs an update for Python3: | ||
if sys.version_info.major > 2: | ||
assert bugtool.data == {} | ||
return | ||
|
||
expected_data = { | ||
"ls -l " | ||
+ __file__: { | ||
"filter": None, | ||
"cap": "xenserver-config", | ||
"cmd_args": [ | ||
"ls", | ||
"-l", | ||
__file__, | ||
], | ||
} | ||
} | ||
assert bugtool.data == expected_data |