Skip to content

Commit

Permalink
fixtures: implement additional fixtures to get data from mh
Browse files Browse the repository at this point in the history
These are getters for selected MultihostFixture properties.
  • Loading branch information
pbrezina committed Sep 13, 2024
1 parent e4cf0ac commit 0a1791f
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pytest_mh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from ._private.artifacts import MultihostArtifactsType, MultihostHostArtifacts, MultihostTopologyControllerArtifacts
from ._private.data import MultihostItemData
from ._private.fixtures import MultihostFixture, mh
from ._private.fixtures import MultihostFixture, mh, mh_config, mh_logger, mh_topology, mh_topology_mark, mh_topology_name
from ._private.marks import KnownTopologyBase, KnownTopologyGroupBase, TopologyMark
from ._private.multihost import (
MultihostBackupHost,
Expand All @@ -28,6 +28,11 @@

__all__ = [
"mh",
"mh_config",
"mh_logger",
"mh_topology",
"mh_topology_mark",
"mh_topology_name",
"KnownTopologyBase",
"KnownTopologyGroupBase",
"MultihostArtifactsType",
Expand Down
67 changes: 67 additions & 0 deletions pytest_mh/_private/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,3 +494,70 @@ def mh(request: pytest.FixtureRequest) -> Generator[MultihostFixture, None, None
mh.split_log_file("test.log")

mh._exit()


@pytest.fixture(scope="function")
def mh_config(mh: MultihostFixture) -> MultihostConfig:
"""
Multihost configuration.
:param mh: mh fixture
:type mh: MultihostFixture
:return: Multihost configuration
:rtype: MultihostConfig
"""
return mh.multihost


@pytest.fixture(scope="function")
def mh_logger(mh: MultihostFixture) -> MultihostLogger:
"""
Multihost logger.
Can be used to log messages into the test log.
:param mh: mh fixture
:type mh: MultihostFixture
:return: Multihost logger.
:rtype: MultihostLogger
"""
return mh.logger


@pytest.fixture(scope="function")
def mh_topology(mh: MultihostFixture) -> Topology:
"""
Current topology.
:param mh: mh fixture
:type mh: MultihostFixture
:return: Current topology
:rtype: Topology
"""
return mh.topology


@pytest.fixture(scope="function")
def mh_topology_name(mh: MultihostFixture) -> Topology:
"""
Current topology name.
:param mh: mh fixture
:type mh: MultihostFixture
:return: Current topology name
:rtype: Topology
"""
return mh.topology_mark.name


@pytest.fixture(scope="function")
def mh_topology_mark(mh: MultihostFixture) -> TopologyMark:
"""
Current topology mark.
:param mh: mh fixture
:type mh: MultihostFixture
:return: Current topology mark
:rtype: TopologyMark
"""
return mh.topology_mark

0 comments on commit 0a1791f

Please sign in to comment.