~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/browser/tests/test_sourcepackagerecipe.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 11265,
        11266, 11267 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
"""Tests for the source package recipe view classes and templates."""
6
6
 
 
7
from __future__ import with_statement
 
8
 
7
9
__metaclass__ = type
8
10
 
9
11
 
28
30
from lp.code.interfaces.sourcepackagerecipe import MINIMAL_RECIPE_TEXT
29
31
from lp.registry.interfaces.pocket import PackagePublishingPocket
30
32
from lp.soyuz.model.processor import ProcessorFamily
31
 
from lp.testing import ANONYMOUS, BrowserTestCase, login, logout
 
33
from lp.testing import (
 
34
    ANONYMOUS, BrowserTestCase, login, logout, person_logged_in)
32
35
from lp.testing.factory import remove_security_proxy_and_shout_at_engineer
33
36
 
34
37
 
303
306
            get_message_text(browser, 2),
304
307
            'There is already a recipe owned by Master Chef with this name.')
305
308
 
 
309
    def test_create_recipe_private_branch(self):
 
310
        # If a user tries to create source package recipe with a private
 
311
        # base branch, they should get an error.
 
312
        branch = self.factory.makeAnyBranch(private=True, owner=self.user)
 
313
        with person_logged_in(self.user):
 
314
            bzr_identity = branch.bzr_identity
 
315
        recipe_text = MINIMAL_RECIPE_TEXT % bzr_identity
 
316
        browser = self.createRecipe(recipe_text)
 
317
        self.assertEqual(
 
318
            get_message_text(browser, 2),
 
319
            'Recipe may not refer to private branch: %s' % bzr_identity)
 
320
 
306
321
 
307
322
class TestSourcePackageRecipeEditView(TestCaseForRecipe):
308
323
    """Test the editing behaviour of a source package recipe."""
475
490
        self.assertTextMatchesExpressionIgnoreWhitespace(
476
491
            pattern, main_text)
477
492
 
 
493
    def test_edit_recipe_private_branch(self):
 
494
        # If a user tries to set source package recipe to use a private
 
495
        # branch, they should get an error.
 
496
        recipe = self.factory.makeSourcePackageRecipe(owner=self.user)
 
497
        branch = self.factory.makeAnyBranch(private=True, owner=self.user)
 
498
        with person_logged_in(self.user):
 
499
            bzr_identity = branch.bzr_identity
 
500
        recipe_text = MINIMAL_RECIPE_TEXT % bzr_identity
 
501
        browser = self.getViewBrowser(recipe, '+edit')
 
502
        browser.getControl('Recipe text').value = recipe_text
 
503
        browser.getControl('Update Recipe').click()
 
504
        self.assertEqual(
 
505
            get_message_text(browser, 1),
 
506
            'Recipe may not refer to private branch: %s' % bzr_identity)
 
507
 
478
508
 
479
509
class TestSourcePackageRecipeView(TestCaseForRecipe):
480
510