Skip to content

Commit

Permalink
Fix netio type missing in actor config
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Nov 24, 2023
1 parent 8ea3ee9 commit 12bfae6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lvmnps/actor/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,13 @@ def get_nps_from_config(config: Configuration) -> NPSClient:

return DLIClient(**init_parameters)

raise RuntimeError("Failed creating NPS client from configuration.")
elif nps_type == "netio":
from lvmnps.nps.implementations.netio import NetIOClient

return NetIOClient(**init_parameters)

else: # pragma: no cover - This should unreachable.
raise ValueError(f"Invalid NPS {nps_type}. Valid types are {VALID_NPS_TYPES}.")


class NPSActor(AMQPActor):
Expand Down
8 changes: 8 additions & 0 deletions tests/test_actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pytest_mock import MockerFixture

from lvmnps.actor.actor import NPSActor
from lvmnps.nps.implementations.netio import NetIOClient


if TYPE_CHECKING:
Expand Down Expand Up @@ -41,6 +42,13 @@ async def test_actor_config_missing(lvmnps_config: Configuration):
NPSActor.from_config(lvmnps_config)


async def test_actor_netio_nps(lvmnps_config: Configuration):
lvmnps_config["nps"]["type"] = "netio"

actor = NPSActor.from_config(lvmnps_config)
assert isinstance(actor.nps, NetIOClient)


async def test_command_status(nps_actor: NPSActor, mocker: MockerFixture):
cmd = await nps_actor.invoke_mock_command("status")
await cmd
Expand Down

0 comments on commit 12bfae6

Please sign in to comment.