72
76
layer = LaunchpadZopelessLayer
78
def setUpParents(self, packages1, packages2):
79
parent1, unused = self.setupParent(packages=packages1)
80
parent2, unused = self.setupParent(packages=packages2)
81
return parent1, parent2
83
def assertBinPackagesAndVersions(self, series, pack_versions):
84
# Helper to assert that series contains the required binaries
85
# pack_version should be of the form [(packagname1, version1), ...]
86
# e.g. [(u'p1', u'0.1-1'), (u'p2', u'2.1')])
87
pub_sources = series.main_archive.getPublishedSources(
90
[(p.getBuiltBinaries()[0].binarypackagerelease.sourcepackagename,
91
p.getBuiltBinaries()[0].binarypackagerelease.version)
92
for p in pub_sources])
94
self.assertEquals(pack_versions, binaries)
74
96
def test_multiple_parents_binary_packages(self):
75
97
# An initialization from many parents (using the package copier)
76
98
# can happen using the same the db user the job will use
77
99
# ('initializedistroseries').
78
self.parent1, unused = self.setupParent(
79
packages={'p1': '0.1-1'})
80
self.parent2, unused = self.setupParent(
81
packages={'p2': '2.1'})
82
child = self.factory.makeDistroSeries()
84
self.layer.switchDbUser('initializedistroseries')
86
child = self._fullInitialize(
87
[self.parent1, self.parent2], child=child)
88
pub_sources = child.main_archive.getPublishedSources(
91
[(p.getBuiltBinaries()[0].binarypackagerelease.sourcepackagename,
92
p.getBuiltBinaries()[0].binarypackagerelease.version)
93
for p in pub_sources])
96
[(u'p1', u'0.1-1'), (u'p2', u'2.1')],
100
parent1, parent2 = self.setUpParents(
101
packages1={'p1': '0.1-1'}, packages2={'p2': '2.1'})
102
child = self.factory.makeDistroSeries()
104
self.layer.switchDbUser('initializedistroseries')
106
child = self._fullInitialize(
107
[parent1, parent2], child=child)
108
self.assertBinPackagesAndVersions(
110
[(u'p1', u'0.1-1'), (u'p2', u'2.1')])
112
def test_multiple_parents_dsd_flag_on(self):
113
# An initialization can happen if the flag for distroseries
114
# difference creation is on.
115
self.useFixture(FeatureFixture({FEATURE_FLAG_ENABLE_MODULE: u'on'}))
116
parent1, parent2 = self.setUpParents(
117
packages1={'p1': '0.1-1'}, packages2={'p2': '2.1'})
118
child = self.factory.makeDistroSeries()
120
self.layer.switchDbUser('initializedistroseries')
122
child = self._fullInitialize(
123
[parent1, parent2], child=child)
124
# Make sure the initialization was successful.
125
self.assertBinPackagesAndVersions(
127
[(u'p1', u'0.1-1'), (u'p2', u'2.1')])
128
# Switch back to launchpad_main to be able to cleanup the
130
self.layer.switchDbUser('launchpad_main')