~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Ian Booth
  • Date: 2011-04-19 15:10:57 UTC
  • mfrom: (12868 devel)
  • mto: This revision was merged to the branch mainline in revision 12983.
  • Revision ID: ian.booth@canonical.com-20110419151057-he56y6k29c4zeiyk
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    )
50
50
from lp.code.interfaces.sourcepackagerecipe import (
51
51
    MINIMAL_RECIPE_TEXT,
52
 
    RECIPE_BETA_FLAG,
53
 
    RECIPE_ENABLED_FLAG,
54
52
    )
55
53
from lp.code.tests.helpers import recipe_parser_newest_version
56
54
from lp.registry.interfaces.person import (
58
56
    )
59
57
from lp.registry.interfaces.pocket import PackagePublishingPocket
60
58
from lp.registry.interfaces.series import SeriesStatus
61
 
from lp.services.features.testing import FeatureFixture
62
59
from lp.services.propertycache import clear_property_cache
63
60
from lp.soyuz.model.processor import ProcessorFamily
64
61
from lp.testing import (
284
281
 
285
282
    layer = DatabaseFunctionalLayer
286
283
 
287
 
    def setUp(self):
288
 
        super(TestSourcePackageRecipeAddView, self).setUp()
289
 
        self.useFixture(
290
 
            FeatureFixture(
291
 
                {RECIPE_ENABLED_FLAG: 'on',
292
 
                 RECIPE_BETA_FLAG: 'true'}))
293
 
 
294
284
    def makeBranch(self):
295
285
        product = self.factory.makeProduct(
296
286
            name='ratatouille', displayname='Ratatouille')
411
401
            browser.getControl('Recipe text').value + 'run cat /etc/passwd')
412
402
        browser.getControl('Create Recipe').click()
413
403
        self.assertEqual(
414
 
            get_message_text(browser, 2),
 
404
            get_feedback_messages(browser.contents)[1],
415
405
            'The bzr-builder instruction "run" is not permitted here.')
416
406
 
417
407
    def createRecipe(self, recipe_text, branch=None):
446
436
            'Error parsing recipe:3:6: '
447
437
            'End of line while looking for the branch id.\n'
448
438
            'Usage: merge NAME BRANCH [REVISION]',
449
 
            get_message_text(browser, 2))
 
439
            get_feedback_messages(browser.contents)[1])
450
440
 
451
441
    def test_create_recipe_no_distroseries(self):
452
442
        browser = self.getViewBrowser(self.makeBranch(), '+new-recipe')
456
446
        browser.getControl('Create Recipe').click()
457
447
        self.assertEqual(
458
448
            'You must specify at least one series for daily builds.',
459
 
            get_message_text(browser, 2))
 
449
            get_feedback_messages(browser.contents)[1])
460
450
 
461
451
    def test_create_recipe_bad_base_branch(self):
462
452
        # If a user tries to create source package recipe with a bad base
463
453
        # branch location, they should get an error.
464
454
        browser = self.createRecipe(MINIMAL_RECIPE_TEXT % 'foo')
465
455
        self.assertEqual(
466
 
            get_message_text(browser, 2), 'foo is not a branch on Launchpad.')
 
456
            get_feedback_messages(browser.contents)[1],
 
457
            'foo is not a branch on Launchpad.')
467
458
 
468
459
    def test_create_recipe_bad_instruction_branch(self):
469
460
        # If a user tries to create source package recipe with a bad
476
467
        recipe += 'nest packaging foo debian'
477
468
        browser = self.createRecipe(recipe, branch)
478
469
        self.assertEqual(
479
 
            get_message_text(browser, 2), 'foo is not a branch on Launchpad.')
 
470
            get_feedback_messages(browser.contents)[1],
 
471
            'foo is not a branch on Launchpad.')
480
472
 
481
473
    def test_create_recipe_format_too_new(self):
482
474
        # If the recipe's format version is too new, we should notify the
493
485
                ''') % branch.bzr_identity
494
486
            browser = self.createRecipe(recipe, branch)
495
487
            self.assertEqual(
496
 
                get_message_text(browser, 2),
 
488
                get_feedback_messages(browser.contents)[1],
497
489
                'The recipe format version specified is not available.')
498
490
 
499
491
    def test_create_dupe_recipe(self):
518
510
        browser.getControl('Create Recipe').click()
519
511
 
520
512
        self.assertEqual(
521
 
            get_message_text(browser, 2),
 
513
            get_feedback_messages(browser.contents)[1],
522
514
            'There is already a recipe owned by Master Chef with this name.')
523
515
 
524
516
    def test_create_recipe_private_branch(self):
530
522
        recipe_text = MINIMAL_RECIPE_TEXT % bzr_identity
531
523
        browser = self.createRecipe(recipe_text)
532
524
        self.assertEqual(
533
 
            get_message_text(browser, 2),
 
525
            get_feedback_messages(browser.contents)[1],
534
526
            'Recipe may not refer to private branch: %s' % bzr_identity)
535
527
 
536
528
    def _test_new_recipe_with_no_related_branches(self, branch):
688
680
        browser.getControl(name='field.ppa_name').value = 'foo'
689
681
        browser.getControl('Create Recipe').click()
690
682
        self.assertEqual(
691
 
            get_message_text(browser, 2),
 
683
            get_feedback_messages(browser.contents)[1],
692
684
            "You already have a PPA named 'foo'.")
693
685
 
694
686
    def test_create_new_ppa_missing_name(self):
706
698
        browser.getControl(name='field.ppa_name').value = ''
707
699
        browser.getControl('Create Recipe').click()
708
700
        self.assertEqual(
709
 
            get_message_text(browser, 2),
 
701
            get_feedback_messages(browser.contents)[1],
710
702
            "You need to specify a name for the PPA.")
711
703
 
712
704
    def test_create_new_ppa_owned_by_recipe_owner(self):
869
861
        browser.getControl('Update Recipe').click()
870
862
 
871
863
        self.assertEqual(
872
 
            extract_text(find_tags_by_class(browser.contents, 'message')[1]),
 
864
            get_feedback_messages(browser.contents)[1],
873
865
            'The bzr-builder instruction "run" is not permitted here.')
874
866
 
875
867
    def test_edit_recipe_format_too_new(self):
899
891
            browser.getControl('Update Recipe').click()
900
892
 
901
893
            self.assertEqual(
902
 
                get_message_text(browser, 1),
 
894
                get_feedback_messages(browser.contents)[1],
903
895
                'The recipe format version specified is not available.')
904
896
 
905
897
    def test_edit_recipe_already_exists(self):
949
941
        browser.getControl('Recipe text').value = recipe_text
950
942
        browser.getControl('Update Recipe').click()
951
943
        self.assertEqual(
952
 
            get_message_text(browser, 1),
 
944
            get_feedback_messages(browser.contents)[1],
953
945
            'Recipe may not refer to private branch: %s' % bzr_identity)
954
946
 
955
947
    def test_edit_recipe_no_branch(self):
962
954
        browser.getControl('Recipe text').value = no_branch_recipe_text
963
955
        browser.getControl('Update Recipe').click()
964
956
        self.assertEqual(
965
 
            get_message_text(browser, 1),
 
957
            get_feedback_messages(browser.contents)[1],
966
958
            'lp://dev/%s is not a branch on Launchpad.' % expected_name)
967
959
 
968
960
    def _test_edit_recipe_with_no_related_branches(self, recipe):