~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/tests/test_distroseries.py

[r=bac,
        julian-edwards][bug=862247] Initialization is not possible if the
        series has no publisher setup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
748
748
        view = create_initialized_view(distroseries, "+initseries")
749
749
        self.assertTrue(view)
750
750
 
 
751
    def test_is_derived_series_feature_disabled(self):
 
752
        # The feature is disabled by default.
 
753
        distroseries = self.factory.makeDistroSeries()
 
754
        view = create_initialized_view(distroseries, "+initseries")
 
755
        with FeatureFixture({}):
 
756
            self.assertFalse(view.is_derived_series_feature_enabled)
 
757
 
751
758
    def test_is_derived_series_feature_enabled(self):
752
759
        # The feature is disabled by default, but can be enabled by setting
753
760
        # the soyuz.derived_series_ui.enabled flag.
754
761
        distroseries = self.factory.makeDistroSeries()
755
 
        view = create_initialized_view(distroseries, "+initseries")
756
 
        with FeatureFixture({}):
757
 
            self.assertFalse(view.is_derived_series_feature_enabled)
758
762
        flags = {u"soyuz.derived_series_ui.enabled": u"true"}
759
763
        with FeatureFixture(flags):
 
764
            view = create_initialized_view(distroseries, "+initseries")
760
765
            self.assertTrue(view.is_derived_series_feature_enabled)
761
766
 
762
767
    def test_form_hidden_when_derived_series_feature_disabled(self):
906
911
                    u'already has initialized series and this distroseries '
907
912
                    u'has no previous series.'))
908
913
 
 
914
    def test_form_hidden_when_no_publisher_config_set_up(self):
 
915
        # If the distribution has no publisher config set up:
 
916
        # the form is hidden and the page contains an error message.
 
917
        distribution = self.factory.makeDistribution(
 
918
            no_pubconf=True, name="distro")
 
919
        distroseries = self.factory.makeDistroSeries(
 
920
            distribution=distribution)
 
921
        view = create_initialized_view(distroseries, "+initseries")
 
922
        flags = {u"soyuz.derived_series_ui.enabled": u"true"}
 
923
        with FeatureFixture(flags):
 
924
            root = html.fromstring(view())
 
925
            self.assertEqual(
 
926
                [], root.cssselect("#initseries-form-container"))
 
927
            # Instead an explanatory message is shown.
 
928
            [message] = root.cssselect("p.error.message")
 
929
            self.assertThat(
 
930
                message.text, EqualsIgnoringWhitespace(
 
931
                    u"The series' distribution has no publisher "
 
932
                    u"configuration. Please ask an administrator to set "
 
933
                    "this up."))
 
934
 
909
935
 
910
936
class TestDistroSeriesInitializeViewAccess(TestCaseWithFactory):
911
937
    """Test access to IDS.+initseries."""