Merge lp:~rockstar/launchpad/create-recipe-error-messages into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Paul Hummer
Approved revision: no longer in the source branch.
Merged at revision: 11154
Proposed branch: lp:~rockstar/launchpad/create-recipe-error-messages
Merge into: lp:launchpad
Diff against target: 46 lines (+17/-4)
2 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+3/-2)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+14/-2)
To merge this branch: bzr merge lp:~rockstar/launchpad/create-recipe-error-messages
Reviewer Review Type Date Requested Status
Jonathan Lange (community) code Approve
Review via email: mp+30253@code.launchpad.net

Description of the change

This branch is a very small fix to pass the bzr-builder exception on to the user when creating a source package recipe. It's bug #604725. I had to change the test a bit so that I could actually construct a real recipe. In fact, since I was sitting next to thumper at the time he found this bug (we knew it existed, but hadn't encountered it yet), I made the test very specific to his exact use case.

I _think_ this test will need to be changed when we update bzr-builder next, because James made some other changes to the exceptions in bzr-builder recently.

To post a comment you must log in.
Revision history for this message
Jonathan Lange (jml) wrote :

On Mon, Jul 19, 2010 at 12:41 PM, Paul Hummer <email address hidden> wrote:
> Paul Hummer has proposed merging lp:~rockstar/launchpad/create-recipe-error-messages into lp:launchpad/devel.
>
> Requested reviews:
>  Jonathan Lange (jml): code
> Related bugs:
>  #604725 Parse errors creating recipe don't show the exception message
>  https://bugs.launchpad.net/bugs/604725
>
>
> This branch is a very small fix to pass the bzr-builder exception on to the user when creating a source package recipe.  It's bug #604725.  I had to change the test a bit so that I could actually construct a real recipe.  In fact, since I was sitting next to thumper at the time he found this bug (we knew it existed, but hadn't encountered it yet), I made the test very specific to his exact use case.

Hey Paul,

This branch looks great. Only one question:

...
> === modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
> --- lib/lp/code/browser/tests/test_sourcepackagerecipe.py       2010-07-13 10:28:38 +0000
> +++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py       2010-07-19 10:41:11 +0000
> @@ -192,10 +192,26 @@
>     def test_create_recipe_bad_text(self):
>         # If a user tries to create source package recipe with bad text, they
>         # should get an error.
> -        browser = self.createRecipe('Foo bar baz')
> +        product = self.factory.makeProduct(
> +            name='ratatouille', displayname='Ratatouille')
> +        branch = self.factory.makeBranch(
> +            owner=self.chef, product=product, name='veggies')
> +        package_branch = self.factory.makeBranch(
> +            owner=self.chef, product=product, name='packaging')
> +

Why is the common product, branch name and branch owner relevant?

Why not:
    branch = self.factory.makeBranch()
    package_branch = self.factory.makeBranch()
?

jml

Revision history for this message
Jonathan Lange (jml) wrote :

See above.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2010-07-13 10:28:38 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2010-07-19 10:55:04 +0000
4@@ -294,10 +294,11 @@
5 try:
6 parser = RecipeParser(data['recipe_text'])
7 parser.parse()
8- except RecipeParseError:
9+ except RecipeParseError, error:
10 self.setFieldError(
11 'recipe_text',
12- 'The recipe text is not a valid bzr-builder recipe.')
13+ 'The recipe text is not a valid bzr-builder recipe. '
14+ '%(error)s' % {'error': error.problem})
15
16
17 class SourcePackageRecipeAddView(RecipeTextValidatorMixin, LaunchpadFormView):
18
19=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
20--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-13 10:28:38 +0000
21+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-07-19 10:55:04 +0000
22@@ -192,10 +192,22 @@
23 def test_create_recipe_bad_text(self):
24 # If a user tries to create source package recipe with bad text, they
25 # should get an error.
26- browser = self.createRecipe('Foo bar baz')
27+ branch = self.factory.makeBranch(name='veggies')
28+ package_branch = self.factory.makeBranch(name='packaging')
29+
30+ browser = self.createRecipe(
31+ dedent('''
32+ # bzr-builder format 0.2 deb-version 0+{revno}
33+ %(branch)s
34+ merge %(package_branch)s
35+ ''' % {
36+ 'branch': branch.bzr_identity,
37+ 'package_branch': package_branch.bzr_identity,}),
38+ branch=branch)
39 self.assertEqual(
40 get_message_text(browser, 2),
41- 'The recipe text is not a valid bzr-builder recipe.')
42+ "The recipe text is not a valid bzr-builder recipe. "
43+ "End of line while looking for '#'")
44
45 def test_create_recipe_no_distroseries(self):
46 browser = self.getViewBrowser(self.makeBranch(), '+new-recipe')