Merge ~twom/launchpad:git-branch-picker-fix-error-message-priority-on-create into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: a1ba4b874bbd344cb7a69705539caaf8ff040700
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:git-branch-picker-fix-error-message-priority-on-create
Merge into: launchpad:master
Diff against target: 39 lines (+18/-0)
2 files modified
lib/lp/oci/browser/ocirecipe.py (+3/-0)
lib/lp/oci/browser/tests/test_ocirecipe.py (+15/-0)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+396675@code.launchpad.net

Commit message

Fix error message order on recipe creation

Description of the change

Same fix as https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/396390, but applied to the Add view as well as the Edit view.

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/oci/browser/ocirecipe.py b/lib/lp/oci/browser/ocirecipe.py
2index 7cf1f94..d1bd570 100644
3--- a/lib/lp/oci/browser/ocirecipe.py
4+++ b/lib/lp/oci/browser/ocirecipe.py
5@@ -806,6 +806,9 @@ class OCIRecipeAddView(LaunchpadFormView, EnableProcessorsMixin,
6 widget = self.widgets["git_ref"]
7 widget.setUpSubWidgets()
8 widget.repository_widget.setRenderedValue(path)
9+ if widget.error():
10+ # Do not override more important git_ref errors.
11+ return
12 default_repo = self.context.getDefaultGitRepository(self.user)
13 if default_repo is None:
14 msg = (
15diff --git a/lib/lp/oci/browser/tests/test_ocirecipe.py b/lib/lp/oci/browser/tests/test_ocirecipe.py
16index 35b9dd8..7c3ccdb 100644
17--- a/lib/lp/oci/browser/tests/test_ocirecipe.py
18+++ b/lib/lp/oci/browser/tests/test_ocirecipe.py
19@@ -446,6 +446,21 @@ class TestOCIRecipeAddView(BaseTestOCIRecipeView):
20 "of this recipe.")
21 self.assertIn(error_message, browser.contents)
22
23+ def test_create_recipe_doesnt_override_gitref_errors(self):
24+ oci_project = self.factory.makeOCIProject()
25+ [git_ref] = self.factory.makeGitRefs()
26+ browser = self.getViewBrowser(
27+ oci_project, view_name="+new-recipe", user=self.person)
28+ browser.getControl(name="field.name").value = "recipe-name"
29+ browser.getControl("Description").value = "Recipe description"
30+ browser.getControl(name="field.git_ref.repository").value = (
31+ git_ref.repository.identity)
32+ browser.getControl(name="field.git_ref.path").value = "non-exist"
33+ browser.getControl("Create OCI recipe").click()
34+
35+ error_message = "does not contain a branch named"
36+ self.assertIn(error_message, browser.contents)
37+
38
39 class TestOCIRecipeAdminView(BaseTestOCIRecipeView):
40

Subscribers

People subscribed via source and target branches

to status/vote changes: