Skip to content

Commit

Permalink
tests: add unit tests for bulk getting and setting
Browse files Browse the repository at this point in the history
Signed-off-by: Jason C. Nucciarone <[email protected]>
  • Loading branch information
NucciTheBoss committed Jul 10, 2024
1 parent cc4b68f commit b49503b
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions tests/unit/test_slurm_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ def test_config_name(self, *_) -> None:
def test_enable(self, subcmd, *_) -> None:
"""Test that the manager calls the correct enable command."""
self.manager.enable()
calls = [args[0][0] for args in subcmd.call_args_list]

args = subcmd.call_args[0][0]
self.assertEqual(
calls[0], ["snap", "start", "--enable", f"slurm.{self.manager._service.value}"]
args, ["snap", "start", "--enable", f"slurm.{self.manager._service.value}"]
)

def test_disable(self, subcmd, *_) -> None:
"""Test that the manager calls the correct disable command."""
self.manager.disable()
calls = [args[0][0] for args in subcmd.call_args_list]

args = subcmd.call_args[0][0]
self.assertEqual(
calls[0], ["snap", "stop", "--disable", f"slurm.{self.manager._service.value}"]
args, ["snap", "stop", "--disable", f"slurm.{self.manager._service.value}"]
)

def test_restart(self, subcmd, *_) -> None:
Expand Down Expand Up @@ -120,6 +120,14 @@ def test_get_config(self, subcmd, *_) -> None:
self.assertEqual(args, ["snap", "get", "-d", "slurm", f"{self.config_name}.key"])
self.assertEqual(value, "value")

def test_get_config_all(self, subcmd) -> None:
"""Test that manager calls the correct `snap get ...` with no arguments given."""
subcmd.return_value = '{"%s": "value"}' % self.config_name
value = self.manager.config.get()
args = subcmd.call_args[0][0]
self.assertEqual(args, ["snap", "get", "-d", "slurm", self.config_name])
self.assertEqual(value, "value")

def test_set_config(self, subcmd, *_) -> None:
"""Test that the manager calls the correct `snap set ...` command."""
self.manager.config.set({"key": "value"})
Expand All @@ -130,7 +138,13 @@ def test_unset_config(self, subcmd) -> None:
"""Test that the manager calls the correct `snap unset ...` command."""
self.manager.config.unset("key")
args = subcmd.call_args[0][0]
self.assertEqual(args, ["snap", "unset", "slurm", f"{self.config_name}.key!"])
self.assertEqual(args, ["snap", "unset", "slurm", f"{self.config_name}.key"])

def test_unset_config_all(self, subcmd) -> None:
"""Test the manager calls the correct `snap unset ...` with no arguments given."""
self.manager.config.unset()
args = subcmd.call_args[0][0]
self.assertEqual(args, ["snap", "unset", "slurm", self.config_name])

def test_generate_munge_key(self, subcmd, *_) -> None:
"""Test that the manager calls the correct `mungectl` command."""
Expand Down

0 comments on commit b49503b

Please sign in to comment.