Skip to content

Commit 6c7b248

Browse files
committed
tests/xapi_plugins/plugin_zfs: add type hints
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent d096055 commit 6c7b248

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

tests/xapi_plugins/plugin_zfs/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import pytest
22

3-
# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py)
43
from lib.host import Host
4+
5+
# Explicitly import package-scoped fixtures (see explanation in pkgfixtures.py)
56
from pkgfixtures import host_with_saved_yum_state, sr_disk_wiped
67

8+
from typing import Generator
9+
710
@pytest.fixture(scope='package')
8-
def host_without_zfs(host):
11+
def host_without_zfs(host: Host) -> Generator[None, None, None]:
912
assert not host.file_exists('/usr/sbin/zpool'), \
1013
"zfs must not be installed on the host at the beginning of the tests"
14+
yield
1115

1216
@pytest.fixture(scope='package')
13-
def host_with_zfs(host_without_zfs: Host, host_with_saved_yum_state: Host):
17+
def host_with_zfs(host_without_zfs: Host, host_with_saved_yum_state: Host) -> Generator[Host, None, None]:
1418
host = host_with_saved_yum_state
1519
host.yum_install(['zfs'])
1620
host.ssh('modprobe zfs')
1721
yield host
1822

1923
@pytest.fixture(scope='package')
20-
def zpool_vol0(sr_disk_wiped, host_with_zfs: Host):
24+
def zpool_vol0(sr_disk_wiped: str, host_with_zfs: Host) -> Generator[None, None, None]:
2125
host_with_zfs.ssh(f'zpool create -f vol0 /dev/{sr_disk_wiped}')
2226
yield
2327
# teardown

tests/xapi_plugins/plugin_zfs/test_zfs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import json
44
import logging
55

6+
from lib.host import Host
7+
68
# Requirements:
79
# From --hosts parameter:
810
# - host(A1): first XCP-ng host > 8.2 with an additional unused disk for the SR.
911
# And:
1012
# - access to XCP-ng RPM repository from hostA1
1113

1214
@pytest.mark.usefixtures("zpool_vol0")
13-
def test_list_zfs_pools(host):
15+
def test_list_zfs_pools(host: Host) -> None:
1416
logging.info("List ZFS pools on host")
1517
res = host.call_plugin('zfs.py', 'list_zfs_pools')
1618
assert json.loads(res).get("vol0") is not None

0 commit comments

Comments
 (0)