From 2a7e8325d85ba090274ada39c47dc53b81233cea Mon Sep 17 00:00:00 2001 From: Pierre Equoy Date: Wed, 10 Apr 2024 09:57:02 +0800 Subject: [PATCH] Format metabox using black Command used: black . --line-length 79 --extend-exclude "/vendor/" --- .../checkbox-core-snap-classic-beta-config.py | 30 +-- metabox/configs/dev-ppa-config.py | 24 +-- metabox/configs/local-source-16.04.py | 6 +- metabox/configs/local-source-18.04.py | 6 +- metabox/configs/local-source-20.04.py | 6 +- metabox/configs/local-source-22.04.py | 6 +- metabox/configs/remote-source-16.04.py | 12 +- metabox/configs/remote-source-18.04.py | 12 +- metabox/configs/remote-source-20.04.py | 12 +- metabox/configs/remote-source-22.04.py | 12 +- metabox/configs/source-local-config.py | 8 +- metabox/configs/source-remote-config.py | 16 +- metabox/configs/testing-ppa-config.py | 24 +-- metabox/metabox/core/actions.py | 56 +++-- metabox/metabox/core/configuration.py | 18 +- metabox/metabox/core/machine.py | 3 +- metabox/metabox/core/runner.py | 10 +- metabox/metabox/core/scenario.py | 6 +- metabox/metabox/metabox-provider/manage.py | 2 +- .../metabox/scenarios/basic/run-invocation.py | 4 +- .../cert_blocker_comment/launcher.py | 196 ++++++++++-------- metabox/metabox/scenarios/config/chains.py | 2 +- metabox/metabox/scenarios/config/daemon.py | 7 +- .../metabox/scenarios/config/environment.py | 71 +++++-- .../metabox/scenarios/config/test_manifest.py | 51 +++-- .../scenarios/config/test_selection.py | 143 ++++++++----- .../scenarios/restart/agent_respawn.py | 1 + metabox/metabox/scenarios/ui/interact_jobs.py | 9 +- metabox/metabox/scenarios/ui/testplan.py | 33 +-- 29 files changed, 460 insertions(+), 326 deletions(-) diff --git a/metabox/configs/checkbox-core-snap-classic-beta-config.py b/metabox/configs/checkbox-core-snap-classic-beta-config.py index 01157a418f..1c3f42a886 100644 --- a/metabox/configs/checkbox-core-snap-classic-beta-config.py +++ b/metabox/configs/checkbox-core-snap-classic-beta-config.py @@ -1,20 +1,20 @@ configuration = { - 'local': { - 'origin': 'classic-snap', - 'checkbox_core_snap': {'risk': 'beta'}, - 'checkbox_snap': {'risk': 'stable'}, - 'releases': ['bionic', 'focal'], + "local": { + "origin": "classic-snap", + "checkbox_core_snap": {"risk": "beta"}, + "checkbox_snap": {"risk": "stable"}, + "releases": ["bionic", "focal"], }, - 'controller': { - 'origin': 'classic-snap', - 'checkbox_core_snap': {'risk': 'beta'}, - 'checkbox_snap': {'risk': 'stable'}, - 'releases': ['focal'], + "controller": { + "origin": "classic-snap", + "checkbox_core_snap": {"risk": "beta"}, + "checkbox_snap": {"risk": "stable"}, + "releases": ["focal"], }, - 'agent': { - 'origin': 'classic-snap', - 'checkbox_core_snap': {'risk': 'beta'}, - 'checkbox_snap': {'risk': 'stable'}, - 'releases': ['bionic', 'focal'], + "agent": { + "origin": "classic-snap", + "checkbox_core_snap": {"risk": "beta"}, + "checkbox_snap": {"risk": "stable"}, + "releases": ["bionic", "focal"], }, } diff --git a/metabox/configs/dev-ppa-config.py b/metabox/configs/dev-ppa-config.py index f9b0bdc45b..dc1d1b979a 100644 --- a/metabox/configs/dev-ppa-config.py +++ b/metabox/configs/dev-ppa-config.py @@ -1,17 +1,17 @@ configuration = { - 'local': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/ppa', - 'releases': ['bionic', 'focal'], + "local": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/ppa", + "releases": ["bionic", "focal"], }, - 'controller': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/ppa', - 'releases': ['focal'], + "controller": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/ppa", + "releases": ["focal"], }, - 'agent': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/ppa', - 'releases': ['bionic', 'focal'], + "agent": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/ppa", + "releases": ["bionic", "focal"], }, } diff --git a/metabox/configs/local-source-16.04.py b/metabox/configs/local-source-16.04.py index b9bf85a29a..271305313d 100644 --- a/metabox/configs/local-source-16.04.py +++ b/metabox/configs/local-source-16.04.py @@ -1,8 +1,8 @@ configuration = { - 'local': { + "local": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['xenial'], + "origin": "source", + "releases": ["xenial"], }, } diff --git a/metabox/configs/local-source-18.04.py b/metabox/configs/local-source-18.04.py index a4d7b55d28..135aca4039 100644 --- a/metabox/configs/local-source-18.04.py +++ b/metabox/configs/local-source-18.04.py @@ -1,8 +1,8 @@ configuration = { - 'local': { + "local": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['bionic'], + "origin": "source", + "releases": ["bionic"], }, } diff --git a/metabox/configs/local-source-20.04.py b/metabox/configs/local-source-20.04.py index 701ed8ae78..921dfb32f8 100644 --- a/metabox/configs/local-source-20.04.py +++ b/metabox/configs/local-source-20.04.py @@ -1,8 +1,8 @@ configuration = { - 'local': { + "local": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['focal'], + "origin": "source", + "releases": ["focal"], }, } diff --git a/metabox/configs/local-source-22.04.py b/metabox/configs/local-source-22.04.py index 2982dfa7a6..cc7c683e5b 100644 --- a/metabox/configs/local-source-22.04.py +++ b/metabox/configs/local-source-22.04.py @@ -1,8 +1,8 @@ configuration = { - 'local': { + "local": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['jammy'], + "origin": "source", + "releases": ["jammy"], }, } diff --git a/metabox/configs/remote-source-16.04.py b/metabox/configs/remote-source-16.04.py index 4f3e2b1545..876e74fe7b 100644 --- a/metabox/configs/remote-source-16.04.py +++ b/metabox/configs/remote-source-16.04.py @@ -1,12 +1,12 @@ configuration = { - 'controller': { + "controller": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['xenial'], + "origin": "source", + "releases": ["xenial"], }, - 'agent': { - 'origin': 'source', - 'releases': ['xenial'], + "agent": { + "origin": "source", + "releases": ["xenial"], }, } diff --git a/metabox/configs/remote-source-18.04.py b/metabox/configs/remote-source-18.04.py index 6d00417bbc..c4bdf87a1b 100644 --- a/metabox/configs/remote-source-18.04.py +++ b/metabox/configs/remote-source-18.04.py @@ -1,12 +1,12 @@ configuration = { - 'controller': { + "controller": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['bionic'], + "origin": "source", + "releases": ["bionic"], }, - 'agent': { - 'origin': 'source', - 'releases': ['bionic'], + "agent": { + "origin": "source", + "releases": ["bionic"], }, } diff --git a/metabox/configs/remote-source-20.04.py b/metabox/configs/remote-source-20.04.py index 6c9891a932..d75cc7bab9 100644 --- a/metabox/configs/remote-source-20.04.py +++ b/metabox/configs/remote-source-20.04.py @@ -1,12 +1,12 @@ configuration = { - 'controller': { + "controller": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['focal'], + "origin": "source", + "releases": ["focal"], }, - 'agent': { - 'origin': 'source', - 'releases': ['focal'], + "agent": { + "origin": "source", + "releases": ["focal"], }, } diff --git a/metabox/configs/remote-source-22.04.py b/metabox/configs/remote-source-22.04.py index 3f73bbbead..16c027bdf3 100644 --- a/metabox/configs/remote-source-22.04.py +++ b/metabox/configs/remote-source-22.04.py @@ -1,12 +1,12 @@ configuration = { - 'controller': { + "controller": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', - 'releases': ['jammy'], + "origin": "source", + "releases": ["jammy"], }, - 'agent': { - 'origin': 'source', - 'releases': ['jammy'], + "agent": { + "origin": "source", + "releases": ["jammy"], }, } diff --git a/metabox/configs/source-local-config.py b/metabox/configs/source-local-config.py index 8ed8dd2b74..b8fb250cef 100644 --- a/metabox/configs/source-local-config.py +++ b/metabox/configs/source-local-config.py @@ -1,10 +1,10 @@ configuration = { - 'local': { + "local": { # Metabox can run tests from a local directory containing a copy of # the Checkbox source code repository. - 'origin': 'source', + "origin": "source", # Path to the Checkbox source code repository - 'uri': '~/dev/work/checkbox', - 'releases': ['focal'], + "uri": "~/dev/work/checkbox", + "releases": ["focal"], }, } diff --git a/metabox/configs/source-remote-config.py b/metabox/configs/source-remote-config.py index 583ee0426a..4cf5ab1e97 100644 --- a/metabox/configs/source-remote-config.py +++ b/metabox/configs/source-remote-config.py @@ -1,12 +1,12 @@ configuration = { - 'controller': { - 'origin': 'source', - 'uri': '~/dev/work/checkbox', - 'releases': ['focal'], + "controller": { + "origin": "source", + "uri": "~/dev/work/checkbox", + "releases": ["focal"], }, - 'agent': { - 'origin': 'source', - 'uri': '~/dev/work/checkbox', - 'releases': ['focal'], + "agent": { + "origin": "source", + "uri": "~/dev/work/checkbox", + "releases": ["focal"], }, } diff --git a/metabox/configs/testing-ppa-config.py b/metabox/configs/testing-ppa-config.py index 5ce59b6fd5..a64bcc3509 100644 --- a/metabox/configs/testing-ppa-config.py +++ b/metabox/configs/testing-ppa-config.py @@ -1,17 +1,17 @@ configuration = { - 'local': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/testing', - 'releases': ['focal', 'jammy'], + "local": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/testing", + "releases": ["focal", "jammy"], }, - 'controller': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/testing', - 'releases': ['focal'], + "controller": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/testing", + "releases": ["focal"], }, - 'agent': { - 'origin': 'ppa', - 'uri': 'ppa:checkbox-dev/testing', - 'releases': ['focal', 'jammy'], + "agent": { + "origin": "ppa", + "uri": "ppa:checkbox-dev/testing", + "releases": ["focal", "jammy"], }, } diff --git a/metabox/metabox/core/actions.py b/metabox/metabox/core/actions.py index cd2388cb5f..32f03e821d 100644 --- a/metabox/metabox/core/actions.py +++ b/metabox/metabox/core/actions.py @@ -22,10 +22,24 @@ """ __all__ = [ - "Start", "Expect", "Send", "SelectTestPlan", - "AssertPrinted", "AssertNotPrinted", "AssertRetCode", - "AssertAgentActive", "Sleep", "RunCmd", "Signal", "Reboot", - "NetUp", "NetDown", "Put", "MkTree", "RunManage", "AssertInFile" + "Start", + "Expect", + "Send", + "SelectTestPlan", + "AssertPrinted", + "AssertNotPrinted", + "AssertRetCode", + "AssertAgentActive", + "Sleep", + "RunCmd", + "Signal", + "Reboot", + "NetUp", + "NetDown", + "Put", + "MkTree", + "RunManage", + "AssertInFile", ] @@ -37,72 +51,72 @@ def __init__(self, *args, **kwargs): self.kwargs = kwargs def __call__(self, scn): - assert(self.handler is not None) + assert self.handler is not None getattr(scn, self.handler)(*self.args, **self.kwargs) class Start(ActionBase): - handler = 'start' + handler = "start" class Expect(ActionBase): - handler = 'expect' + handler = "expect" class ExpectNot(ActionBase): - handler = 'expect_not' + handler = "expect_not" class Send(ActionBase): - handler = 'send' + handler = "send" class SelectTestPlan(ActionBase): - handler = 'select_test_plan' + handler = "select_test_plan" class AssertPrinted(ActionBase): - handler = 'assert_printed' + handler = "assert_printed" class AssertNotPrinted(ActionBase): - handler = 'assert_not_printed' + handler = "assert_not_printed" class AssertRetCode(ActionBase): - handler = 'assert_ret_code' + handler = "assert_ret_code" class AssertAgentActive(ActionBase): - handler = 'is_agent_active' + handler = "is_agent_active" class Sleep(ActionBase): - handler = 'sleep' + handler = "sleep" class RunCmd(ActionBase): - handler = 'run_cmd' + handler = "run_cmd" class Signal(ActionBase): - handler = 'signal' + handler = "signal" class Reboot(ActionBase): - handler = 'reboot' + handler = "reboot" class NetUp(ActionBase): - handler = 'switch_on_networking' + handler = "switch_on_networking" class NetDown(ActionBase): - handler = 'switch_off_networking' + handler = "switch_off_networking" class Put(ActionBase): - handler = 'put' + handler = "put" class MkTree(ActionBase): diff --git a/metabox/metabox/core/configuration.py b/metabox/metabox/core/configuration.py index 127e6f0e6d..6d128f4464 100644 --- a/metabox/metabox/core/configuration.py +++ b/metabox/metabox/core/configuration.py @@ -104,8 +104,10 @@ def _has_local_or_remote_declaration(config): True """ - return bool(config.get('local') or ( - config.get('agent') and config.get('controller'))) + return bool( + config.get("local") + or (config.get("agent") and config.get("controller")) + ) def _decl_has_a_valid_origin(decl): @@ -161,9 +163,15 @@ def _decl_has_a_valid_origin(decl): logger.error("Failed to dry-run install {}", setup_file_location) raise if "checkbox-ng" not in package_dry_install_log.stdout: - logger.error("{} did not install a package named `checkbox-ng`", source) - logger.error("Installation stdout:\n{}", package_dry_install_log.stdout) - logger.error("Installation stderr:\n{}", package_dry_install_log.stderr) + logger.error( + "{} did not install a package named `checkbox-ng`", source + ) + logger.error( + "Installation stdout:\n{}", package_dry_install_log.stdout + ) + logger.error( + "Installation stderr:\n{}", package_dry_install_log.stderr + ) return False return True return False diff --git a/metabox/metabox/core/machine.py b/metabox/metabox/core/machine.py index 9260339695..199f00d754 100644 --- a/metabox/metabox/core/machine.py +++ b/metabox/metabox/core/machine.py @@ -391,8 +391,7 @@ def get_early_setup(self): gid=0, ) self.mock_inxi_at( - "/home/ubuntu/checkbox/checkbox-ng" - "/plainbox/vendor/inxi" + "/home/ubuntu/checkbox/checkbox-ng" "/plainbox/vendor/inxi" ) return commands diff --git a/metabox/metabox/core/runner.py b/metabox/metabox/core/runner.py index 6253822ef2..7b9a4f0a2f 100644 --- a/metabox/metabox/core/runner.py +++ b/metabox/metabox/core/runner.py @@ -82,7 +82,9 @@ def _gather_all_machine_spec(self): revisions = self._get_revisions_jobs() for controller_revision, agent_revision in revisions: controller_config["revision"] = controller_revision - self.combo.add(MachineConfig("controller", controller_config)) + self.combo.add( + MachineConfig("controller", controller_config) + ) agent_config["revision"] = agent_revision self.combo.add(MachineConfig("agent", agent_config)) elif v.mode == "local": @@ -143,7 +145,7 @@ def setup(self): mode_to_role = { "remote": "controller", "local": "local", - "agent": "agent" + "agent": "agent", } role = mode_to_role[mode] if role not in self.config: @@ -259,7 +261,9 @@ def run(self): total = len(self.scn_variants) for idx, scn in enumerate(self.scn_variants, 1): if scn.mode == "remote": - scn.controller_machine = self._load("controller", scn.releases[0]) + scn.controller_machine = self._load( + "controller", scn.releases[0] + ) scn.agent_machine = self._load("agent", scn.releases[1]) scn.controller_machine.rollback_to("provisioned") scn.agent_machine.rollback_to("provisioned") diff --git a/metabox/metabox/core/scenario.py b/metabox/metabox/core/scenario.py index dd8ac16f2a..ed7753bf49 100644 --- a/metabox/metabox/core/scenario.py +++ b/metabox/metabox/core/scenario.py @@ -101,7 +101,7 @@ def run(self): interactive = False # CHECK if any EXPECT/SEND command follows # w/o a new call to START before it - for next_step in self.steps[i + 1:]: + for next_step in self.steps[i + 1 :]: if isinstance(next_step, Start): break if isinstance(next_step, (Expect, Send, SelectTestPlan)): @@ -147,9 +147,7 @@ def assert_not_printed(self, pattern): """ regex = re.compile(pattern) if self._pts: - found = regex.search( - self._pts.stdout_data_full - ) + found = regex.search(self._pts.stdout_data_full) else: found = regex.search(self._stdout) or regex.search(self._stderr) self._checks.append(not found) diff --git a/metabox/metabox/metabox-provider/manage.py b/metabox/metabox/metabox-provider/manage.py index 7dc5255a70..7c98814a41 100755 --- a/metabox/metabox/metabox-provider/manage.py +++ b/metabox/metabox/metabox-provider/manage.py @@ -2,7 +2,7 @@ from plainbox.provider_manager import setup, N_ setup( - name='2021.com.canonical.certification:metabox', + name="2021.com.canonical.certification:metabox", version="1.0", description=N_("The 2021.com.canonical.certification:metabox provider"), gettext_domain="2021_com_canonical_certification_metabox", diff --git a/metabox/metabox/scenarios/basic/run-invocation.py b/metabox/metabox/scenarios/basic/run-invocation.py index 8cc4e913d1..35dd24ed93 100644 --- a/metabox/metabox/scenarios/basic/run-invocation.py +++ b/metabox/metabox/scenarios/basic/run-invocation.py @@ -75,9 +75,7 @@ class RunManualplan(Scenario): Send(keys.KEY_ENTER), Expect("Pick an action"), Send("p" + keys.KEY_ENTER), - Expect( - "A simple user interaction and verification job" - ), + Expect("A simple user interaction and verification job"), ] diff --git a/metabox/metabox/scenarios/cert_blocker_comment/launcher.py b/metabox/metabox/scenarios/cert_blocker_comment/launcher.py index b99a73333e..215687e91c 100644 --- a/metabox/metabox/scenarios/cert_blocker_comment/launcher.py +++ b/metabox/metabox/scenarios/cert_blocker_comment/launcher.py @@ -31,8 +31,9 @@ class ManualJobFailed(Scenario): entered. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -41,20 +42,21 @@ class ManualJobFailed(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), - Send('f' + keys.KEY_ENTER), - Expect('Please add a comment to explain why it failed.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('f' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☒|job failed).*A simple manual job')), + Expect("Pick an action"), + Send("f" + keys.KEY_ENTER), + Expect("Please add a comment to explain why it failed.", timeout=30), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("f" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☒|job failed).*A simple manual job")), ] @@ -64,8 +66,9 @@ class ManualJobSkipped(Scenario): "blocker" and make sure it can only be skipped if a comment is entered. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -74,20 +77,24 @@ class ManualJobSkipped(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Please add a comment to explain why you want to skip it.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☐|job skipped).*A simple manual job')), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect( + "Please add a comment to explain why you want to skip it.", + timeout=30, + ), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☐|job skipped).*A simple manual job")), ] @@ -98,8 +105,9 @@ class UserInteractVerifyJobFailed(Scenario): is entered. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -108,22 +116,23 @@ class UserInteractVerifyJobFailed(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), + Expect("Pick an action"), Send(keys.KEY_ENTER), - Expect('job needs verification', timeout=30), - Send('f' + keys.KEY_ENTER), - Expect('Please add a comment to explain why it failed.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('f' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☒|job failed).*user interaction and verification job')), + Expect("job needs verification", timeout=30), + Send("f" + keys.KEY_ENTER), + Expect("Please add a comment to explain why it failed.", timeout=30), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("f" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☒|job failed).*user interaction and verification job")), ] @@ -134,8 +143,9 @@ class UserInteractVerifyJobSkippedAfterRun(Scenario): entered after actually running it. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -144,22 +154,26 @@ class UserInteractVerifyJobSkippedAfterRun(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), + Expect("Pick an action"), Send(keys.KEY_ENTER), - Expect('job needs verification', timeout=30), - Send('s' + keys.KEY_ENTER), - Expect('Please add a comment to explain why you want to skip it.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☐|job skipped).*user interaction and verification job')), + Expect("job needs verification", timeout=30), + Send("s" + keys.KEY_ENTER), + Expect( + "Please add a comment to explain why you want to skip it.", + timeout=30, + ), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☐|job skipped).*user interaction and verification job")), ] @@ -170,8 +184,9 @@ class UserInteractVerifyJobSkippedBeforeRun(Scenario): entered before actually running it. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -180,20 +195,24 @@ class UserInteractVerifyJobSkippedBeforeRun(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Please add a comment to explain why you want to skip it.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☐|job skipped).*user interaction and verification job')), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect( + "Please add a comment to explain why you want to skip it.", + timeout=30, + ), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☐|job skipped).*user interaction and verification job")), ] @@ -204,8 +223,9 @@ class UserInteractJobSkippedBeforeRun(Scenario): before actually running it. """ - modes = ['local'] - launcher = textwrap.dedent(""" + modes = ["local"] + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -214,18 +234,22 @@ class UserInteractJobSkippedBeforeRun(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Please add a comment to explain why you want to skip it.', timeout=30), - Send('c' + keys.KEY_ENTER), - Expect('Please enter your comments:'), - Send('This is a comment' + keys.KEY_ENTER), - Expect('Pick an action'), - Send('s' + keys.KEY_ENTER), - Expect('Select jobs to re-run'), - Send('f' + keys.KEY_ENTER), - Expect(_re('(☐|job skipped).*User-interact job')), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect( + "Please add a comment to explain why you want to skip it.", + timeout=30, + ), + Send("c" + keys.KEY_ENTER), + Expect("Please enter your comments:"), + Send("This is a comment" + keys.KEY_ENTER), + Expect("Pick an action"), + Send("s" + keys.KEY_ENTER), + Expect("Select jobs to re-run"), + Send("f" + keys.KEY_ENTER), + Expect(_re("(☐|job skipped).*User-interact job")), ] diff --git a/metabox/metabox/scenarios/config/chains.py b/metabox/metabox/scenarios/config/chains.py index e8524ae05c..f9c6c642c1 100644 --- a/metabox/metabox/scenarios/config/chains.py +++ b/metabox/metabox/scenarios/config/chains.py @@ -24,7 +24,7 @@ Start, Put, Send, - RunCmd + RunCmd, ) from metabox.core.scenario import Scenario from metabox.core.utils import tag diff --git a/metabox/metabox/scenarios/config/daemon.py b/metabox/metabox/scenarios/config/daemon.py index 1f5ddefb7d..353009d0e1 100644 --- a/metabox/metabox/scenarios/config/daemon.py +++ b/metabox/metabox/scenarios/config/daemon.py @@ -128,6 +128,7 @@ class DaemonNormalUserDoesntExist(Scenario): AssertPrinted("User 'testuser' doesn't exist!"), ] + @tag("daemon", "agent", "normal_user") class NewNameForDaemonWorks(Scenario): modes = ["remote"] @@ -150,6 +151,7 @@ class NewNameForDaemonWorks(Scenario): AssertPrinted("User 'testuser' doesn't exist!"), ] + @tag("daemon", "agent", "normal_user") class DeprecatedDaemon(Scenario): modes = ["remote"] @@ -169,6 +171,7 @@ class DeprecatedDaemon(Scenario): ) steps = [ Start(), - AssertPrinted("Config: daemon section name is deprecated. Use agent instead."), + AssertPrinted( + "Config: daemon section name is deprecated. Use agent instead." + ), ] - diff --git a/metabox/metabox/scenarios/config/environment.py b/metabox/metabox/scenarios/config/environment.py index 190dfab43b..11665b9a9d 100644 --- a/metabox/metabox/scenarios/config/environment.py +++ b/metabox/metabox/scenarios/config/environment.py @@ -28,7 +28,9 @@ class CheckboxConfEnvvarCaseSensitive(Scenario): """ Check that environment variables are case sensitive """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -41,7 +43,8 @@ class CheckboxConfEnvvarCaseSensitive(Scenario): CASE = CASE Case = Case case = case - """) + """ + ) steps = [ AssertPrinted("CASE"), AssertPrinted("Case"), @@ -54,8 +57,10 @@ class CheckboxConfXDG(Scenario): Check that environment variables are read from the XDG directory when nothing else is available. """ + checkbox_conf = read_text(environment, "checkbox_etc_xdg.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -64,7 +69,8 @@ class CheckboxConfXDG(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Put("/etc/xdg/checkbox.conf", checkbox_conf), Start(), @@ -77,9 +83,11 @@ class CheckboxConfLocalHome(Scenario): Check that environment variables are read from the $HOME directory when nothing else is available. """ + modes = ["local"] checkbox_conf = read_text(environment, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -88,7 +96,8 @@ class CheckboxConfLocalHome(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ MkTree("/home/ubuntu/.config/"), Put("/home/ubuntu/.config/checkbox.conf", checkbox_conf), @@ -102,9 +111,11 @@ class CheckboxConfRemoteHome(Scenario): Check that environment variables are read from the $HOME directory when nothing else is available. """ + modes = ["remote"] checkbox_conf = read_text(environment, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -113,7 +124,8 @@ class CheckboxConfRemoteHome(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ MkTree("/root/.config/", privileged=True), Put("/root/.config/checkbox.conf", checkbox_conf), @@ -127,9 +139,11 @@ class CheckboxConfSnap(Scenario): Check that environment variables are read from the $SNAP_DATA directory when nothing else is available. """ + origins = ["snap", "classic-snap"] checkbox_conf = read_text(environment, "checkbox_snap_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -138,7 +152,8 @@ class CheckboxConfSnap(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ MkTree("/var/snap/checkbox/current/"), Put("/var/snap/checkbox/current/checkbox.conf", checkbox_conf), @@ -152,7 +167,9 @@ class CheckboxConfLauncher(Scenario): Check that environment variables are read from the launcher when nothing else is available. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -163,7 +180,8 @@ class CheckboxConfLauncher(Scenario): forced = yes [environment] source = LAUNCHER - """) + """ + ) steps = [ AssertPrinted("source: LAUNCHER"), ] @@ -174,10 +192,12 @@ class CheckboxConfLocalHomePrecedence(Scenario): Check that the environment variables defined in the ~/.config/ directory take precedence over the ones defined in /etc/xdg/. """ + modes = ["local"] checkbox_conf_xdg = read_text(environment, "checkbox_etc_xdg.conf") checkbox_conf_home = read_text(environment, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -186,7 +206,8 @@ class CheckboxConfLocalHomePrecedence(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Put("/etc/xdg/checkbox.conf", checkbox_conf_xdg), MkTree("/home/ubuntu/.config/"), @@ -201,9 +222,11 @@ class CheckboxConfLauncherPrecedence(Scenario): Check that the environment variables defined in the launcher take precedence over the ones defined in /etc/xdg/. """ + modes = ["remote"] checkbox_conf_xdg = read_text(environment, "checkbox_etc_xdg.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -214,7 +237,8 @@ class CheckboxConfLauncherPrecedence(Scenario): forced = yes [environment] source = REMOTE LAUNCHER - """) + """ + ) steps = [ Put("/etc/xdg/checkbox.conf", checkbox_conf_xdg), Start(), @@ -238,10 +262,12 @@ class CheckboxConfLocalResolutionOrder(Scenario): var3 XDG ---------------------> """ + modes = ["local"] checkbox_conf_xdg = read_text(environment, "checkbox_etc_xdg.conf") checkbox_conf_home = read_text(environment, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -252,7 +278,8 @@ class CheckboxConfLocalResolutionOrder(Scenario): forced = yes [environment] var1 = LAUNCHER - """) + """ + ) steps = [ Put("/etc/xdg/checkbox.conf", checkbox_conf_xdg), MkTree("/home/ubuntu/.config/"), @@ -273,10 +300,12 @@ class CheckboxConfRemoteAgentResolutionOrder(Scenario): This scenario sets 3 environment variables in different config locations and checks the resolution order is as defined. """ + modes = ["remote"] checkbox_conf_xdg = read_text(environment, "checkbox_etc_xdg.conf") checkbox_conf_home = read_text(environment, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -292,9 +321,7 @@ class CheckboxConfRemoteAgentResolutionOrder(Scenario): steps = [ Put("/etc/xdg/checkbox.conf", checkbox_conf_xdg, target="agent"), MkTree("/root/.config", privileged=True), - Put( - "/root/.config/checkbox.conf", checkbox_conf_home, target="agent" - ), + Put("/root/.config/checkbox.conf", checkbox_conf_home, target="agent"), Start(), AssertPrinted("variables: HOME LAUNCHER XDG"), ] diff --git a/metabox/metabox/scenarios/config/test_manifest.py b/metabox/metabox/scenarios/config/test_manifest.py index d6def285d7..5ea2ef2848 100644 --- a/metabox/metabox/scenarios/config/test_manifest.py +++ b/metabox/metabox/scenarios/config/test_manifest.py @@ -25,7 +25,6 @@ Put, Send, MkTree, - ) from metabox.core.scenario import Scenario from metabox.core.utils import tag @@ -34,6 +33,7 @@ conf_wrong = read_text(test_manifest, "wrong.json") + @tag("manifest", "normal_user") class ManifestLauncherAuto(Scenario): """ @@ -42,7 +42,8 @@ class ManifestLauncherAuto(Scenario): tests selection was skipped or not """ - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] @@ -53,10 +54,12 @@ class ManifestLauncherAuto(Scenario): forced = yes [manifest] 2021.com.canonical.certification::manifest_location = 0 - """) + """ + ) steps = [AssertPrinted(".*Outcome: job passed.*")] + @tag("manifest", "normal_user") class ManifestLauncherManual(Scenario): """ @@ -65,7 +68,8 @@ class ManifestLauncherManual(Scenario): tests selection was skipped or not """ - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] @@ -74,7 +78,8 @@ class ManifestLauncherManual(Scenario): unit = 2021.com.canonical.certification::manifest_test_support [manifest] 2021.com.canonical.certification::manifest_location = 0 - """) + """ + ) steps = [ Expect("tests to run on your system"), @@ -83,9 +88,10 @@ class ManifestLauncherManual(Scenario): Send("T"), Expect("job passed"), Expect("job passed"), - Expect("Test the resolution order of the manifest") + Expect("Test the resolution order of the manifest"), ] + @tag("manifest", "normal_user") class ManifestConfigCacheAuto(Scenario): """ @@ -95,7 +101,8 @@ class ManifestConfigCacheAuto(Scenario): conf_correct = read_text(test_manifest, "correct.json") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] @@ -104,7 +111,8 @@ class ManifestConfigCacheAuto(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ MkTree("/var/tmp/checkbox-ng"), @@ -113,6 +121,7 @@ class ManifestConfigCacheAuto(Scenario): AssertPrinted(".*Outcome: job passed.*"), ] + @tag("manifest", "normal_user") class ManifestConfigCacheManual(Scenario): """ @@ -122,14 +131,16 @@ class ManifestConfigCacheManual(Scenario): conf_correct = read_text(test_manifest, "correct.json") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] # filtering to avoid the test being out of bound forced = yes unit = 2021.com.canonical.certification::manifest_test_support - """) + """ + ) steps = [ MkTree("/var/tmp/checkbox-ng"), @@ -141,9 +152,10 @@ class ManifestConfigCacheManual(Scenario): Send("T"), Expect("job passed"), Expect("job passed"), - Expect("Test the resolution order of the manifest") + Expect("Test the resolution order of the manifest"), ] + @tag("manifest", "normal_user") class ManifestConfigPrecedenceAuto(Scenario): """ @@ -154,7 +166,8 @@ class ManifestConfigPrecedenceAuto(Scenario): conf_wrong = read_text(test_manifest, "wrong.json") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] @@ -165,15 +178,17 @@ class ManifestConfigPrecedenceAuto(Scenario): forced = yes [manifest] 2021.com.canonical.certification::manifest_location = 0 - """) + """ + ) steps = [ MkTree("/var/tmp/checkbox-ng"), Put("/var/tmp/checkbox-ng/machine-manifest.json", conf_wrong), Start(), - AssertPrinted(".*Outcome: job passed.*") + AssertPrinted(".*Outcome: job passed.*"), ] + @tag("manifest", "normal_user") class ManifestConfigPrecedenceManual(Scenario): """ @@ -184,7 +199,8 @@ class ManifestConfigPrecedenceManual(Scenario): conf_wrong = read_text(test_manifest, "wrong.json") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 [test plan] @@ -193,7 +209,8 @@ class ManifestConfigPrecedenceManual(Scenario): unit = 2021.com.canonical.certification::manifest_test_support [manifest] 2021.com.canonical.certification::manifest_location = 0 - """) + """ + ) steps = [ MkTree("/var/tmp/checkbox-ng"), @@ -205,5 +222,5 @@ class ManifestConfigPrecedenceManual(Scenario): Send("T"), Expect("job passed"), Expect("job passed"), - Expect("Test the resolution order of the manifest") + Expect("Test the resolution order of the manifest"), ] diff --git a/metabox/metabox/scenarios/config/test_selection.py b/metabox/metabox/scenarios/config/test_selection.py index 6e5db66755..db5037fada 100644 --- a/metabox/metabox/scenarios/config/test_selection.py +++ b/metabox/metabox/scenarios/config/test_selection.py @@ -18,8 +18,15 @@ import textwrap from importlib.resources import read_text -from metabox.core.actions import AssertPrinted, AssertNotPrinted, Expect,\ - Start, Put, Send, MkTree +from metabox.core.actions import ( + AssertPrinted, + AssertNotPrinted, + Expect, + Start, + Put, + Send, + MkTree, +) from metabox.core.scenario import Scenario from .config_files import test_selection @@ -29,14 +36,17 @@ class TestSelectionDefault(Scenario): """ Check that by default, the list of tests to run is displayed. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text [test plan] unit = com.canonical.certification::smoke forced = yes - """) + """ + ) steps = [ Start(), Expect("Choose tests to run on your system:"), @@ -47,7 +57,9 @@ class TestSelectionForced(Scenario): """ If test selection is forced, Checkbox should start testing right away. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -57,7 +69,8 @@ class TestSelectionForced(Scenario): forced = yes [test selection] forced = yes - """) + """ + ) steps = [ Start(), # Jobs are started right away without test selection screen, e.g. @@ -70,7 +83,9 @@ class TestSelectionExcludedJob(Scenario): """ If some jobs are excluded from the launcher, they should not be run. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -80,7 +95,8 @@ class TestSelectionExcludedJob(Scenario): [test selection] forced = yes exclude = .*config-environ-source - """) + """ + ) steps = [ Start(), AssertNotPrinted(".*config-environ-source.*"), @@ -100,10 +116,12 @@ class LocalTestSelectionResolution(Scenario): This scenario tests this in local mode. """ + modes = ["local"] checkbox_conf_etc = read_text(test_selection, "checkbox_etc_xdg.conf") checkbox_conf_home = read_text(test_selection, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -113,7 +131,8 @@ class LocalTestSelectionResolution(Scenario): [test selection] exclude = forced = yes - """) + """ + ) steps = [ MkTree("/home/ubuntu/.config"), Put("/home/ubuntu/.config/checkbox.conf", checkbox_conf_home), @@ -136,10 +155,12 @@ class RemoteTestSelectionResolution(Scenario): This scenario tests this in remote mode. """ + modes = ["remote"] checkbox_conf_etc = read_text(test_selection, "checkbox_etc_xdg.conf") checkbox_conf_home = read_text(test_selection, "checkbox_home_dir.conf") - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -149,17 +170,21 @@ class RemoteTestSelectionResolution(Scenario): [test selection] exclude = forced = yes - """) + """ + ) steps = [ MkTree("/home/ubuntu/.config", target="agent"), - Put("/home/ubuntu/.config/checkbox.conf", checkbox_conf_home, - target="agent"), - Put("/etc/xdg/checkbox.conf", checkbox_conf_etc, - target="agent"), + Put( + "/home/ubuntu/.config/checkbox.conf", + checkbox_conf_home, + target="agent", + ), + Put("/etc/xdg/checkbox.conf", checkbox_conf_etc, target="agent"), Start(), AssertPrinted(".*config-environ-source.*"), ] + class TestPlanSelectionSkip(Scenario): """ If the launcher file lists a unit and forces the selection @@ -168,30 +193,34 @@ class TestPlanSelectionSkip(Scenario): This scenario has to work locally and remotely """ + # the conf file should be overwritten by the launcher, # if it is not, this will make the test fail intentionally checkbox_conf = read_text( test_selection, "checkbox_testplan_unit_forced.conf" ) - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text [test plan] unit = com.canonical.certification::smoke forced = yes - """) + """ + ) steps = [ MkTree("/home/ubuntu/.config", target="agent"), - Put("/home/ubuntu/.config/checkbox.conf", - checkbox_conf, target="agent"), - Put("/etc/xdg/checkbox.conf", checkbox_conf, - target = "agent"), + Put( + "/home/ubuntu/.config/checkbox.conf", checkbox_conf, target="agent" + ), + Put("/etc/xdg/checkbox.conf", checkbox_conf, target="agent"), Start(), # Assert that we have reached test selection - Expect("Choose tests to run on your system") + Expect("Choose tests to run on your system"), ] + class TestPlanPreselected(Scenario): """ If the launcher selects a unit, it should be selected @@ -199,12 +228,14 @@ class TestPlanPreselected(Scenario): This scenario has to work locally and remotely """ + # the conf file should be overwritten by the launcher, # if it is not, this will make the test fail intentionally checkbox_conf = read_text( test_selection, "checkbox_testplan_unit_forced.conf" ) - launcher = textwrap.dedent(""" + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -213,27 +244,31 @@ class TestPlanPreselected(Scenario): # filtering to avoid the test being out of bound filter = *smoke* unit = com.canonical.certification::smoke - """) + """ + ) steps = [ MkTree("/home/ubuntu/.config", target="agent"), - Put("/home/ubuntu/.config/checkbox.conf", - checkbox_conf, target="agent"), - Put("/etc/xdg/checkbox.conf", checkbox_conf, - target = "agent"), + Put( + "/home/ubuntu/.config/checkbox.conf", checkbox_conf, target="agent" + ), + Put("/etc/xdg/checkbox.conf", checkbox_conf, target="agent"), Start(), - #( ) Some other test - #(X) All Smoke Tests - #( ) Some other test - Expect("(X)") + # ( ) Some other test + # (X) All Smoke Tests + # ( ) Some other test + Expect("(X)"), ] + class TestPlanSelectionPreselectFailWrongName(Scenario): """ If a test with an unknown name is selected via unit checkbox should exit providing an error explaining that it did not find the test plan. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text @@ -243,10 +278,10 @@ class TestPlanSelectionPreselectFailWrongName(Scenario): unit = this_unit_does_not_exist # This forces to continue but nothing is selected forced = yes - """) - steps = [ - AssertPrinted(".*The test plan .+ is not available!.*") - ] + """ + ) + steps = [AssertPrinted(".*The test plan .+ is not available!.*")] + class TestPlanSelectionPreselectNothing(Scenario): """ @@ -254,47 +289,57 @@ class TestPlanSelectionPreselectNothing(Scenario): or forced to do so in the test plan selection screen it should quit given that no test plan was selected. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text [test plan] # This forces to continue but nothing is selected forced = yes - """) + """ + ) steps = [ - AssertPrinted(".*The test plan selection was forced but no unit was provided") + AssertPrinted( + ".*The test plan selection was forced but no unit was provided" + ) ] + class TestPlanSelectionFilterEmpty(Scenario): """ If a filter excludes every test, checkbox should exit printing an error. """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text [test plan] # This should not match any valid test name (no word, no digit) filter = [^\w\d] - """) + """ + ) steps = [ Expect("There were no test plans to select from"), ] + class TestPlanSelectionFilter(Scenario): """ Test plan selection should be filtered from the launcher """ - launcher = textwrap.dedent(""" + + launcher = textwrap.dedent( + """ [launcher] launcher_version = 1 stock_reports = text [test plan] filter = com.canonical.certification::[!s]* - """) - steps = [ - Send("i"), - AssertNotPrinted("smoke") - ] + """ + ) + steps = [Send("i"), AssertNotPrinted("smoke")] diff --git a/metabox/metabox/scenarios/restart/agent_respawn.py b/metabox/metabox/scenarios/restart/agent_respawn.py index 1d571503ef..3ab7ea0162 100644 --- a/metabox/metabox/scenarios/restart/agent_respawn.py +++ b/metabox/metabox/scenarios/restart/agent_respawn.py @@ -129,6 +129,7 @@ class ResumeAfterFinishPreserveOutputLocal(Scenario): Expect("job failed"), ] + @tag("resume", "manual") class ResumeAfterFinishPreserveOutputRemote(Scenario): modes = ["remote"] diff --git a/metabox/metabox/scenarios/ui/interact_jobs.py b/metabox/metabox/scenarios/ui/interact_jobs.py index 9a36b248bc..da9072c893 100644 --- a/metabox/metabox/scenarios/ui/interact_jobs.py +++ b/metabox/metabox/scenarios/ui/interact_jobs.py @@ -18,12 +18,7 @@ import textwrap import metabox.core.keys as keys -from metabox.core.actions import ( - Expect, - Send, - Start, - ExpectNot -) +from metabox.core.actions import Expect, Send, Start, ExpectNot from metabox.core.scenario import Scenario from metabox.core.utils import tag @@ -51,5 +46,5 @@ class ManualInteractQuit(Scenario): Send("q" + keys.KEY_ENTER), # if q is pressed, checkbox should exit instead of going ahead printing # results - ExpectNot("Results") + ExpectNot("Results"), ] diff --git a/metabox/metabox/scenarios/ui/testplan.py b/metabox/metabox/scenarios/ui/testplan.py index a323157132..59ba1f3d5b 100644 --- a/metabox/metabox/scenarios/ui/testplan.py +++ b/metabox/metabox/scenarios/ui/testplan.py @@ -25,25 +25,26 @@ class UrwidTestPlanSelection(Scenario): - modes = ['local'] + modes = ["local"] steps = [ - Expect('Select test plan'), - #SelectTestPlan('com.canonical.certification::stress-pm-graph'), - #SelectTestPlan( + Expect("Select test plan"), + # SelectTestPlan('com.canonical.certification::stress-pm-graph'), + # SelectTestPlan( # 'com.canonical.certification::' # 'after-suspend-graphics-discrete-gpu-cert-automated'), SelectTestPlan( - 'com.canonical.certification::client-cert-desktop-18-04'), + "com.canonical.certification::client-cert-desktop-18-04" + ), Send(keys.KEY_ENTER), - Expect('Choose tests to run on your system:'), - Send('d' + keys.KEY_ENTER), - Expect('Choose tests to run on your system:'), - #Send(keys.KEY_DOWN * 18 + keys.KEY_SPACE + 't'), - #Expect('System Manifest:'), - #Send('y' * 11 + 't'), - Send('t'), - #Expect('Pick an action'), - #Send('s' + keys.KEY_ENTER), - #Expect('Finish'), - #Send('f' + keys.KEY_ENTER), + Expect("Choose tests to run on your system:"), + Send("d" + keys.KEY_ENTER), + Expect("Choose tests to run on your system:"), + # Send(keys.KEY_DOWN * 18 + keys.KEY_SPACE + 't'), + # Expect('System Manifest:'), + # Send('y' * 11 + 't'), + Send("t"), + # Expect('Pick an action'), + # Send('s' + keys.KEY_ENTER), + # Expect('Finish'), + # Send('f' + keys.KEY_ENTER), ]