~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_distroseries_vocabularies.py

Add DistroSeriesInitializeView.rebuilding_allowed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
from pytz import utc
14
14
from testtools.matchers import Equals
15
15
from zope.component import getUtility
16
 
from zope.schema.interfaces import (
17
 
    IVocabularyFactory,
18
 
    )
 
16
from zope.schema.interfaces import IVocabularyFactory
19
17
from zope.security.proxy import removeSecurityProxy
20
18
 
21
19
from canonical.database.sqlbase import flush_database_caches
70
68
        # the vocabulary factory returns a vocabulary for all distroseries of
71
69
        # the distribution from which the derived series have been derived.
72
70
        parent_distroseries = self.factory.makeDistroSeries()
73
 
        # Create a sibling to the parent.
74
71
        self.factory.makeDistroSeries(
75
72
            distribution=parent_distroseries.distribution)
76
 
        distroseries = self.factory.makeDistroSeries(
77
 
            previous_series=parent_distroseries)
 
73
        distroseries = self.factory.makeDistroSeries()
 
74
        self.factory.makeDistroSeriesParent(
 
75
            derived_series=distroseries, parent_series=parent_distroseries)
78
76
        vocabulary = DistroSeriesDerivationVocabulary(distroseries)
79
77
        expected_distroseries = set(parent_distroseries.distribution.series)
80
78
        observed_distroseries = set(term.value for term in vocabulary)
81
79
        self.assertEqual(expected_distroseries, observed_distroseries)
82
80
 
 
81
    def test_distribution_with_derived_series_from_multiple_parents(self):
 
82
        # Given a distribution with series, one or more of which are derived
 
83
        # from multiple parents, the vocabulary factory returns a vocabulary
 
84
        # for all distroseries of the distribution*s* from which the derived
 
85
        # series have been derived.
 
86
        parent_distroseries = self.factory.makeDistroSeries()
 
87
        another_parent_distroseries = self.factory.makeDistroSeries()
 
88
        self.factory.makeDistroSeries(
 
89
            distribution=parent_distroseries.distribution)
 
90
        distroseries = self.factory.makeDistroSeries()
 
91
        self.factory.makeDistroSeriesParent(
 
92
            derived_series=distroseries, parent_series=parent_distroseries)
 
93
        self.factory.makeDistroSeriesParent(
 
94
            derived_series=distroseries,
 
95
            parent_series=another_parent_distroseries)
 
96
        vocabulary = DistroSeriesDerivationVocabulary(distroseries)
 
97
        expected_distroseries = set(
 
98
            parent_distroseries.distribution.series).union(
 
99
                set(another_parent_distroseries.distribution.series))
 
100
        observed_distroseries = set(term.value for term in vocabulary)
 
101
        self.assertEqual(expected_distroseries, observed_distroseries)
 
102
 
83
103
    def test_distribution_with_derived_series_of_self(self):
84
104
        # Given a distribution with series derived from other of its series
85
105
        # (which shouldn't happen), the vocabulary factory returns a
87
107
        # given distribution.
88
108
        parent_distroseries = self.factory.makeDistroSeries()
89
109
        distroseries = self.factory.makeDistroSeries(
90
 
            distribution=parent_distroseries.distribution,
91
 
            previous_series=parent_distroseries)
 
110
            distribution=parent_distroseries.distribution)
 
111
        self.factory.makeDistroSeriesParent(
 
112
            derived_series=distroseries, parent_series=parent_distroseries)
92
113
        vocabulary = DistroSeriesDerivationVocabulary(distroseries)
93
114
        expected_distroseries = (
94
115
            set(self.all_distroseries).difference(
168
189
        distribution = self.factory.makeDistribution()
169
190
        parent_distroseries = self.factory.makeDistroSeries()
170
191
        distroseries = self.factory.makeDistroSeries(
171
 
            previous_series=parent_distroseries,
172
192
            distribution=distribution)
 
193
        self.factory.makeDistroSeriesParent(
 
194
            derived_series=distroseries, parent_series=parent_distroseries)
173
195
        flush_database_caches()
174
196
        # Reload distroseries and distribution; these will reasonably already
175
197
        # be loaded before using the vocabulary.