7675.883.1
by Steve Kowalik
* First shot at the deriveDistroSeries() function, and exporting it over the |
1 |
# Copyright 2010 Canonical Ltd. This software is licensed under the
|
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
3 |
||
4 |
"""Test initialising a distroseries using
|
|
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
5 |
IDistroSeries.initDerivedDistroSeries."""
|
7675.883.1
by Steve Kowalik
* First shot at the deriveDistroSeries() function, and exporting it over the |
6 |
|
7 |
__metaclass__ = type |
|
8 |
||
12494.1.79
by Gavin Panella
In deriveDistoSeries() ensure that child.parent_series is None. |
9 |
from zope.component import getUtility |
10 |
from zope.security.interfaces import Unauthorized |
|
11 |
from zope.security.proxy import removeSecurityProxy |
|
12 |
||
7675.883.1
by Steve Kowalik
* First shot at the deriveDistroSeries() function, and exporting it over the |
13 |
from canonical.testing.layers import LaunchpadFunctionalLayer |
7675.883.6
by Steve Kowalik
* Add DerivationError which gives us webservice errors, and use it for |
14 |
from lp.registry.interfaces.distroseries import DerivationError |
7675.883.7
by Steve Kowalik
* Fix lint issues, remove stray XXX |
15 |
from lp.soyuz.interfaces.distributionjob import ( |
16 |
IInitialiseDistroSeriesJobSource, |
|
17 |
)
|
|
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
18 |
from lp.testing import ( |
13011.2.1
by Julian Edwards
IDistroSeries.deriveDistroSeries() now requires lp.edit to work |
19 |
ANONYMOUS, |
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
20 |
login, |
13011.2.1
by Julian Edwards
IDistroSeries.deriveDistroSeries() now requires lp.edit to work |
21 |
login_person, |
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
22 |
TestCaseWithFactory, |
23 |
)
|
|
7675.883.7
by Steve Kowalik
* Fix lint issues, remove stray XXX |
24 |
|
7675.883.1
by Steve Kowalik
* First shot at the deriveDistroSeries() function, and exporting it over the |
25 |
|
26 |
class TestDeriveDistroSeries(TestCaseWithFactory): |
|
27 |
||
28 |
layer = LaunchpadFunctionalLayer |
|
29 |
||
30 |
def setUp(self): |
|
31 |
super(TestDeriveDistroSeries, self).setUp() |
|
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
32 |
self.parent = self.factory.makeDistroSeries() |
12494.1.79
by Gavin Panella
In deriveDistoSeries() ensure that child.parent_series is None. |
33 |
self.child = self.factory.makeDistroSeries() |
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
34 |
removeSecurityProxy(self.child).driver = self.factory.makePerson() |
35 |
login_person(self.child.driver) |
|
7675.883.7
by Steve Kowalik
* Fix lint issues, remove stray XXX |
36 |
|
37 |
def test_no_permission_to_call(self): |
|
13011.2.1
by Julian Edwards
IDistroSeries.deriveDistroSeries() now requires lp.edit to work |
38 |
login(ANONYMOUS) |
7675.883.7
by Steve Kowalik
* Fix lint issues, remove stray XXX |
39 |
self.assertRaises( |
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
40 |
Unauthorized, getattr, self.child, "initDerivedDistroSeries") |
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
41 |
|
12494.1.79
by Gavin Panella
In deriveDistoSeries() ensure that child.parent_series is None. |
42 |
def test_parent_is_not_set(self): |
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
43 |
# When the series already has a parent series, it means that the
|
44 |
# distroseries has already been derived, and it is forbidden to
|
|
45 |
# derive more than once.
|
|
46 |
self.factory.makeDistroSeriesParent( |
|
47 |
derived_series=self.child, parent_series=self.parent) |
|
7675.883.4
by Steve Kowalik
* Rename state to status, and make a lot of the arguments optional. |
48 |
self.assertRaisesWithContent( |
7675.883.6
by Steve Kowalik
* Add DerivationError which gives us webservice errors, and use it for |
49 |
DerivationError, |
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
50 |
("DistroSeries {self.child.name} already has parent " |
51 |
"series.".format(self=self)), |
|
52 |
self.child.initDerivedDistroSeries, self.child.driver, |
|
13117.2.7
by Raphael Badin
Pass parents by id to initDerivedSeries. |
53 |
[self.parent.id]) |
7675.883.1
by Steve Kowalik
* First shot at the deriveDistroSeries() function, and exporting it over the |
54 |
|
13117.2.3
by Raphael Badin
Fix series initialisation to use DSP (and not previous_series). |
55 |
def test_init_creates_new_job(self): |
56 |
self.child.initDerivedDistroSeries( |
|
13117.2.7
by Raphael Badin
Pass parents by id to initDerivedSeries. |
57 |
self.child.driver, [self.parent.id]) |
7675.883.7
by Steve Kowalik
* Fix lint issues, remove stray XXX |
58 |
[job] = list( |
59 |
getUtility(IInitialiseDistroSeriesJobSource).iterReady()) |
|
60 |
self.assertEqual(job.distroseries, self.child) |