~gmb/launchpad/bug-644346

« back to all changes in this revision

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

  • Committer: Graham Binns
  • Date: 2010-09-23 08:59:28 UTC
  • mfrom: (11575.1.37 launchpad)
  • Revision ID: graham@canonical.com-20100923085928-4x8vlt72gvzppb11
Merged devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    SourcePackageRecipeBuildView,
41
41
    )
42
42
from lp.code.interfaces.sourcepackagerecipe import MINIMAL_RECIPE_TEXT
 
43
from lp.code.tests.helpers import recipe_parser_newest_version
43
44
from lp.registry.interfaces.pocket import PackagePublishingPocket
44
45
from lp.soyuz.model.processor import ProcessorFamily
45
46
from lp.testing import (
46
47
    ANONYMOUS,
47
48
    BrowserTestCase,
48
49
    login,
49
 
    logout,
50
50
    person_logged_in,
51
51
    )
52
52
from lp.testing.factory import remove_security_proxy_and_shout_at_engineer
103
103
        return branch
104
104
 
105
105
    def test_create_new_recipe_not_logged_in(self):
106
 
        from canonical.launchpad.testing.pages import setupBrowser
107
106
        product = self.factory.makeProduct(
108
107
            name='ratatouille', displayname='Ratatouille')
109
108
        branch = self.factory.makeBranch(
110
109
            owner=self.chef, product=product, name='veggies')
111
 
        branch_url = canonical_url(branch)
112
 
        logout()
113
 
 
114
 
        browser = setupBrowser()
115
 
        browser.open(branch_url)
116
 
 
 
110
 
 
111
        browser = self.getViewBrowser(branch, no_login=True)
117
112
        self.assertRaises(
118
113
            Unauthorized, browser.getLink('Create packaging recipe').click)
119
114
 
310
305
        self.assertEqual(
311
306
            get_message_text(browser, 2), 'foo is not a branch on Launchpad.')
312
307
 
 
308
    def test_create_recipe_format_too_new(self):
 
309
        # If the recipe's format version is too new, we should notify the
 
310
        # user.
 
311
        product = self.factory.makeProduct(
 
312
            name='ratatouille', displayname='Ratatouille')
 
313
        branch = self.factory.makeBranch(
 
314
            owner=self.chef, product=product, name='veggies')
 
315
 
 
316
        with recipe_parser_newest_version(145.115):
 
317
            recipe = dedent(u'''\
 
318
                # bzr-builder format 145.115 deb-version 0+{revno}
 
319
                %s
 
320
                ''') % branch.bzr_identity
 
321
            browser = self.createRecipe(recipe, branch)
 
322
            self.assertEqual(
 
323
                get_message_text(browser, 2),
 
324
                'The recipe format version specified is not available.')
 
325
 
313
326
    def test_create_dupe_recipe(self):
314
327
        # You shouldn't be able to create a duplicate recipe owned by the same
315
328
        # person with the same name.
689
702
            set([2605]),
690
703
            set(build.buildqueue_record.lastscore for build in builds))
691
704
 
 
705
    def test_request_builds_action_not_logged_in(self):
 
706
        """Requesting a build creates pending builds."""
 
707
        woody = self.factory.makeDistroSeries(
 
708
            name='woody', displayname='Woody',
 
709
            distribution=self.ppa.distribution)
 
710
        naked_woody = removeSecurityProxy(woody)
 
711
        naked_woody.nominatedarchindep = woody.newArch(
 
712
            'i386', ProcessorFamily.get(1), False, self.factory.makePerson(),
 
713
            supports_virtualized=True)
 
714
        recipe = self.makeRecipe()
 
715
 
 
716
        browser = self.getViewBrowser(recipe, no_login=True)
 
717
        self.assertRaises(
 
718
            Unauthorized, browser.getLink('Request build(s)').click)
 
719
 
692
720
    def test_request_builds_archive(self):
693
721
        recipe = self.factory.makeSourcePackageRecipe()
694
722
        ppa2 = self.factory.makeArchive(