From 1cc75e02ddd2854d28170e3b077adc1b5c5168c4 Mon Sep 17 00:00:00 2001 From: mulhern Date: Sun, 3 Dec 2023 22:36:58 -0500 Subject: [PATCH] Add some simple tests for coverage Signed-off-by: mulhern --- .github/workflows/main.yml | 1 + .../whitebox/integration/pool/test_report.py | 60 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tests/whitebox/integration/pool/test_report.py diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05069f74e..d71e16b22 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,6 +125,7 @@ jobs: python3-psutil python3-wcwidth systemd-devel + util-linux - uses: dtolnay/rust-toolchain@master with: components: cargo diff --git a/tests/whitebox/integration/pool/test_report.py b/tests/whitebox/integration/pool/test_report.py new file mode 100644 index 000000000..4db1bb059 --- /dev/null +++ b/tests/whitebox/integration/pool/test_report.py @@ -0,0 +1,60 @@ +# Copyright 2022 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Test 'report'. +""" +# isort: STDLIB +from uuid import uuid4 + +# isort: FIRSTPARTY +from dbus_client_gen import DbusClientUniqueResultError + +# isort: LOCAL +from stratis_cli import StratisCliErrorCodes + +from .._misc import RUNNER, TEST_RUNNER, SimTestCase, device_name_list + +_ERROR = StratisCliErrorCodes.ERROR +_DEVICE_STRATEGY = device_name_list(1, 1) + + +class ReportTestCase(SimTestCase): + """ + Test 'report' on a sim pool. + """ + + _MENU = ["--propagate", "pool", "report"] + _POOLNAME = "poolname" + + def setUp(self): + super().setUp() + command_line = ["pool", "create", self._POOLNAME] + _DEVICE_STRATEGY() + RUNNER(command_line) + + def test_call_bad_uuid(self): + """ + Test bad uuid + """ + command_line = self._MENU + ["--uuid", str(uuid4())] + self.check_error(DbusClientUniqueResultError, command_line, _ERROR) + + def test_report_bad_name(self): + """ + Test bad name. + """ + command_line = self._MENU + [ + "--name", + "noone", + ] + self.check_error(DbusClientUniqueResultError, command_line, _ERROR)