Skip to content

Commit 22a76e3

Browse files
committed
Add early check of mandatory fields in *_device_config() fixtures
Signed-off-by: Yann Dirson <[email protected]>
1 parent f356a59 commit 22a76e3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/config.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
ignore_ssh_banner = False
22
ssh_output_max_lines = 20
33

4-
def sr_device_config(datakey):
4+
def sr_device_config(datakey, *, required=[]):
55
import data # import here to avoid depending on this user file for collecting tests
6-
return getattr(data, datakey)
6+
config = getattr(data, datakey)
7+
for required_field in required:
8+
if required_field not in config:
9+
raise Exception(f"{datakey} lacks mandatory {required_field!r}")
10+
return config

tests/storage/iso/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def local_iso_sr(host, formatted_and_mounted_ext4_disk):
2626

2727
@pytest.fixture(scope='module')
2828
def nfs_iso_device_config():
29-
return config.sr_device_config("NFS_ISO_DEVICE_CONFIG")
29+
return config.sr_device_config("NFS_ISO_DEVICE_CONFIG", required=['location'])
3030

3131
@pytest.fixture(scope='module')
3232
def cifs_iso_device_config():

0 commit comments

Comments
 (0)