Skip to content

Commit 0b5fa58

Browse files
committed
testcases: introduce get_exported_shares() helper function
Avoid directly accessing the test_info dict and use helper function instead. This will allow us to modify the test_info.yml with minimal disruption. Signed-off-by: Sachin Prabhu <[email protected]>
1 parent 16a06ce commit 0b5fa58

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

testcases/consistency/test_consistency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def generate_consistency_check(
6262
return []
6363
arr = []
6464
for ipaddr in test_info_file["public_interfaces"]:
65-
for share_name in test_info_file["exported_sharenames"]:
65+
for share_name in testhelper.get_exported_shares(test_info):
6666
arr.append((ipaddr, share_name))
6767
return arr
6868

testcases/containers/test_containers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def generate_containers_test() -> typing.List[typing.Tuple[str, str, str]]:
6969
# Use the first given public_interface for our tests
7070
ipaddr = test_info["public_interfaces"][0]
7171
arr = []
72-
for share_name in test_info["exported_sharenames"]:
72+
for share_name in testhelper.get_exported_shares(test_info):
7373
for test in container_tests.keys():
7474
arr.append((ipaddr, share_name, test))
7575
return arr

testcases/misc/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def setup_mount(
4747

4848
def gen_params() -> typing.List[typing.Any]:
4949
ipaddr = test_info["public_interfaces"][0]
50-
exported_sharenames = test_info.get("exported_sharenames", [])
50+
exported_sharenames = testhelper.get_exported_shares(test_info)
5151
arr = []
5252
for share_name in exported_sharenames:
5353
arr.append(

testcases/smbtorture/test_smbtorture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def list_smbtorture_tests():
114114
def generate_smbtorture_tests() -> typing.List[typing.Tuple[str, str]]:
115115
smbtorture_info = list_smbtorture_tests()
116116
arr = []
117-
for share_name in test_info.get("exported_sharenames", []):
117+
for share_name in testhelper.get_exported_shares(test_info):
118118
for torture_test in smbtorture_info:
119119
arr.append((share_name, torture_test))
120120
return arr

testhelper/testhelper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,14 @@ def get_premounted_shares(test_info: dict) -> typing.List[Path]:
8787
"""
8888
premounted_shares = test_info.get("premounted_shares", [])
8989
return [Path(mnt) for mnt in premounted_shares]
90+
91+
92+
def get_exported_shares(test_info: dict) -> typing.List[str]:
93+
"""Get the list of exported shares
94+
95+
Parameters:
96+
test_info: Dict containing the parsed yaml file.
97+
Returns:
98+
list of exported shares
99+
"""
100+
return test_info.get("exported_sharenames", [])

0 commit comments

Comments
 (0)