Merge lp:~kissiel/checkbox/fix-1492320-comment-on-manual-fail into lp:checkbox

Proposed by Maciej Kisielewski
Status: Merged
Approved by: Zygmunt Krynicki
Approved revision: 4097
Merged at revision: 4106
Proposed branch: lp:~kissiel/checkbox/fix-1492320-comment-on-manual-fail
Merge into: lp:checkbox
Diff against target: 175 lines (+65/-12)
6 files modified
checkbox-touch/checkbox-touch.qml (+14/-1)
plainbox/docs/changelog.rst (+5/-0)
plainbox/docs/manpages/plainbox-job-units.rst (+6/-0)
plainbox/plainbox/impl/commands/inv_run.py (+8/-0)
plainbox/plainbox/impl/unit/job.py (+21/-11)
plainbox/plainbox/impl/unit/test_job.py (+11/-0)
To merge this branch: bzr merge lp:~kissiel/checkbox/fix-1492320-comment-on-manual-fail
Reviewer Review Type Date Requested Status
Zygmunt Krynicki (community) Approve
Paul Larson Approve
Review via email: mp+276657@code.launchpad.net

Description of the change

This MR makes checkboxes ask for comment when the user manually fails the test.

7dc29b7 plainbox:unit:job: add validation of 'explicit-fail' flag
9495c9b plainbox:unit:job: fix pep-8 issues
9e335d0 checkbox-touch: support 'explicit-fail' flag
b2c842d plainbox:commands:run: support 'explicit-fail' in plainbox and checkbox-ng
b2d9c14 plainbox:docs: mention 'explicit-fail' in the changelog
31db2cc plainbox:docs:manpages: mention 'explicit-fail' in job unit manpage

To post a comment you must log in.
4092. By Maciej Kisielewski

plainbox:unit:job: add validation of 'explicit-fail' flag

This patch adds validation of 'explicit-fail' flag.

Signed-off-by: Maciej Kisielewski <email address hidden>

4093. By Maciej Kisielewski

plainbox:unit:job: fix pep-8 issues

Signed-off-by: Maciej Kisielewski <email address hidden>

4094. By Maciej Kisielewski

checkbox-touch: support 'explicit-fail' flag

This patch makes checkbox-touch display the 'add-comment' popup when user fails
a job that flagged as 'explicit-fail'.

Fixes: https://bugs.launchpad.net/checkbox-converged/+bug/1492320

Signed-off-by: Maciej Kisielewski <email address hidden>

4095. By Maciej Kisielewski

plainbox:commands:run: support 'explicit-fail' in plainbox and checkbox-ng

This patch brings support for 'explicit-fail' flag to CLI flavours of checkbox.

Fixes: https://bugs.launchpad.net/checkbox-converged/+bug/1492320

Signed-off-by: Maciej Kisielewski <email address hidden>

4096. By Maciej Kisielewski

plainbox:docs: mention 'explicit-fail' in the changelog

Signed-off-by: Maciej Kisielewski <email address hidden>

4097. By Maciej Kisielewski

plainbox:docs:manpages: mention 'explicit-fail' in job unit manpage

Signed-off-by: Maciej Kisielewski <email address hidden>

Revision history for this message
Paul Larson (pwlars) wrote :

I don't know that I have an easy way to test this personally, but happy to try if you can walk me through it. Otherwise, I can give it a +1 as a sanity check.

review: Approve
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

Looks good.

I'd like to stress that we need to figure out a way to share improvements like that with session assistant-based applications. We should plan a sprint around the user interface re-usability class so that each new feature transparently lands in all applications based on SA (unless they opt-out by subclassing something)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'checkbox-touch/checkbox-touch.qml'
2--- checkbox-touch/checkbox-touch.qml 2015-11-02 09:09:00 +0000
3+++ checkbox-touch/checkbox-touch.qml 2015-11-04 14:36:11 +0000
4@@ -667,7 +667,20 @@
5
6 function showVerificationScreen(test) {
7 var verificationPage = createPage("components/TestVerificationPage.qml", test);
8- verificationPage.testDone.connect(completeTest);
9+ var maybeCommentVerification = function(test) {
10+ if (test.outcome == 'fail' &&
11+ test.flags.indexOf('explicit-fail') > -1) {
12+ commentsDialog.commentDefaultText = test["comments"] || "";
13+ commentsDialog.commentAdded.connect(function(comment) {
14+ test["comments"] = comment;
15+ completeTest(test);
16+ });
17+ PopupUtils.open(commentsDialog.dialogComponent);
18+ } else {
19+ completeTest(test);
20+ }
21+ }
22+ verificationPage.testDone.connect(maybeCommentVerification);
23 pageStack.push(verificationPage);
24 }
25 function getSubmissionInput(continuation, cancelContinuation) {
26
27=== modified file 'plainbox/docs/changelog.rst'
28--- plainbox/docs/changelog.rst 2015-11-04 08:36:33 +0000
29+++ plainbox/docs/changelog.rst 2015-11-04 14:36:11 +0000
30@@ -16,6 +16,11 @@
31 option when you know your way around, and you want to quickly start
32 developing plainbox jobs without any other jobs polluting your provider.
33
34+* Plainbox now supports a new flag :ref:`explicit-fail
35+ <job_flag_explicit_fail>`. Using that flag makes manual failing of the job
36+ require a comment to be entered. This flag naturally makes sense only for
37+ 'manual', 'user-interact-verify', 'user-verify' jobs.
38+
39 .. _version_0_24:
40
41 Plainbox 0.24
42
43=== modified file 'plainbox/docs/manpages/plainbox-job-units.rst'
44--- plainbox/docs/manpages/plainbox-job-units.rst 2015-09-28 13:20:53 +0000
45+++ plainbox/docs/manpages/plainbox-job-units.rst 2015-11-04 14:36:11 +0000
46@@ -265,6 +265,12 @@
47 Attach this flag to jobs that cause killing of plainbox process during
48 their operation. E.g. run shutdown, reboot, etc.
49
50+.. _job_flag_explicit_fail:
51+
52+ ``explicit-fail``:
53+ Use this flag to make entering comment mandatory, when the user
54+ manually fails the job.
55+
56 .. _job_flag_has_leftovers:
57
58 ``has-leftovers``:
59
60=== modified file 'plainbox/plainbox/impl/commands/inv_run.py'
61--- plainbox/plainbox/impl/commands/inv_run.py 2015-09-25 07:36:02 +0000
62+++ plainbox/plainbox/impl/commands/inv_run.py 2015-11-04 14:36:11 +0000
63@@ -929,9 +929,17 @@
64 print(" " + _("comments") + ": {0}".format(
65 self.C.CYAN(result.comments, bright=False)))
66 cmd = self._pick_action_cmd(allowed_actions)
67+ # let's store new_comment early for verification if comment has
68+ # already been added in the current UI step
69+ new_comment = ''
70 if cmd == 'set-pass':
71 result_builder.outcome = IJobResult.OUTCOME_PASS
72 elif cmd == 'set-fail':
73+ if 'explicit-fail' in job.get_flag_set() and not new_comment:
74+ new_comment = input(self.C.BLUE(
75+ _('Please enter your comments:') + '\n'))
76+ if new_comment:
77+ result_builder.add_comment(new_comment)
78 result_builder.outcome = IJobResult.OUTCOME_FAIL
79 elif cmd == 'set-skip' or cmd is None:
80 result_builder.outcome = IJobResult.OUTCOME_SKIP
81
82=== modified file 'plainbox/plainbox/impl/unit/job.py'
83--- plainbox/plainbox/impl/unit/job.py 2015-09-28 13:20:53 +0000
84+++ plainbox/plainbox/impl/unit/job.py 2015-11-04 14:36:11 +0000
85@@ -455,8 +455,8 @@
86 for stage in ['purpose', 'steps', 'verification']:
87 stage_value = self.get_translated_record_value(stage)
88 if stage_value is not None:
89- tr_description += (tr_stages[stage] + ':\n'
90- + stage_value + '\n')
91+ tr_description += (tr_stages[stage] + ':\n' +
92+ stage_value + '\n')
93 tr_description = tr_description.strip()
94 if not tr_description:
95 # combining new description yielded empty string
96@@ -800,8 +800,8 @@
97 " fields. See http://plainbox.readthedocs.org"
98 "/en/latest/author/faq.html#faq-2"),
99 onlyif=lambda unit:
100- unit.startup_user_interaction_required
101- and unit.get_record_value('summary') is None),
102+ unit.startup_user_interaction_required and
103+ unit.get_record_value('summary') is None),
104 ],
105 fields.steps: [
106 TranslatableFieldValidator,
107@@ -817,9 +817,9 @@
108 TranslatableFieldValidator,
109 PresentFieldValidator(
110 severity=Severity.advice,
111- message = ("please use purpose, steps, and verification"
112- " fields. See http://plainbox.readthedocs.org"
113- "/en/latest/author/faq.html#faq-2"),
114+ message=("please use purpose, steps, and verification"
115+ " fields. See http://plainbox.readthedocs.org"
116+ "/en/latest/author/faq.html#faq-2"),
117 onlyif=lambda unit: unit.plugin in (
118 'manual', 'user-verify', 'user-interact-verify')),
119 ],
120@@ -957,6 +957,16 @@
121 ' non-C locale then set the preserve-locale flag'
122 ),
123 onlyif=lambda unit: unit.command),
124+ CorrectFieldValueValidator(
125+ lambda value, unit: (
126+ not ('explicit-fail' in unit.get_flag_set() and
127+ unit.plugin in {
128+ 'shell', 'user-interact', 'attachment',
129+ 'local', 'resource'})),
130+ Problem.useless, Severity.advice,
131+ message=_('explicit-fail makes no sense for job which '
132+ 'outcome is automatically determined.')
133+ ),
134 # The has-leftovers flag is useless without a command
135 CorrectFieldValueValidator(
136 lambda value, unit: (
137@@ -976,13 +986,13 @@
138 lambda value: value.endswith('.qml'),
139 Problem.wrong, Severity.advice,
140 message=_('use the .qml extension for all QML files'),
141- onlyif=lambda unit: (unit.plugin == 'qml'
142- and unit.qml_file)),
143+ onlyif=lambda unit: (unit.plugin == 'qml' and
144+ unit.qml_file)),
145 CorrectFieldValueValidator(
146 lambda value, unit: os.path.isfile(unit.qml_file),
147 message=_('please point to an existing QML file'),
148- onlyif=lambda unit: (unit.plugin == 'qml'
149- and unit.qml_file)),
150+ onlyif=lambda unit: (unit.plugin == 'qml' and
151+ unit.qml_file)),
152 ],
153 fields.certification_status: [
154 UntranslatableFieldValidator,
155
156=== modified file 'plainbox/plainbox/impl/unit/test_job.py'
157--- plainbox/plainbox/impl/unit/test_job.py 2015-09-25 08:39:43 +0000
158+++ plainbox/plainbox/impl/unit/test_job.py 2015-11-04 14:36:11 +0000
159@@ -736,6 +736,17 @@
160 issue_list, self.unit_cls.Meta.fields.flags,
161 Problem.expected_i18n, Severity.advice, message)
162
163+ def test_flags__usless_explicit_fail_on_shell_jobs(self):
164+ message = ("field 'flags', explicit-fail makes no sense for job which "
165+ "outcome is automatically determined.")
166+ issue_list = self.unit_cls({
167+ 'plugin': 'shell',
168+ 'flags': 'explicit-fail'
169+ }, provider=self.provider).check()
170+ self.assertIssueFound(
171+ issue_list, self.unit_cls.Meta.fields.flags,
172+ Problem.useless, Severity.advice, message)
173+
174
175 class JobDefinitionValidatorTests(TestCase):
176

Subscribers

People subscribed via source and target branches