~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
DistroSeries source publishing lookups
======================================

IDistroSeries allows source publishing lookup via
getReleasedPackages method which returns a shortlist of
ISourcePackagePublishingHistory ordered by descending ID.

In order to test its behavior we will create a bunch of sample
publishing records with different (status, pocket, archive) in
ubuntu/breezy-autotest, which is empty:

    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> from lp.registry.interfaces.person import IPersonSet
    >>> from lp.registry.interfaces.pocket import PackagePublishingPocket

    >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
    >>> breezy_autotest = ubuntu['breezy-autotest']
    >>> cprov_archive = getUtility(IPersonSet).getByName('cprov').archive

We will use a 'cnews' sourcepackage because it's not published yet in
the distroseries we want to test, this will help to make the tests as clear
as possible.

    >>> hoary = ubuntu['hoary']
    >>> cnews_hoary = hoary.getSourcePackage('cnews')
    >>> sample_spr = cnews_hoary.currentrelease.sourcepackagerelease

    >>> from lp.soyuz.model.publishing import (
    ...    SourcePackagePublishingHistory)

    >>> SourcePackagePublishingHistory.selectBy(
    ...     distroseries=breezy_autotest,
    ...     sourcepackagerelease=sample_spr).count()
    0

Create and collect several binary publishing records in a variety of
states, pockets and archives:

    >>> from lp.soyuz.tests.soyuz import SoyuzTestHelper

    >>> soyuz_helper = SoyuzTestHelper()
    >>> sample_pub = soyuz_helper.createPublishingForDistroSeries(
    ...      sample_spr, breezy_autotest)

    >>> [pub_main_release_pending, pub_main_release_published,
    ...  pub_main_updates_pending, pub_main_proposed_published,
    ...  pub_ppa_release_pending, pub_ppa_release_published,
    ...  pub_ppa_updates_pending, pub_ppa_proposed_published] = sample_pub


Looking for all PUBLISHED publications in main_archive and all
pockets:

    >>> import operator
    >>> all_published_main_pubs = [
    ...     pub_main_proposed_published,
    ...     pub_main_release_published,
    ...     ]

    >>> all_published_main_pubs = sorted(
    ...    all_published_main_pubs, key=operator.attrgetter('id'),
    ...    reverse=True)

    >>> result = breezy_autotest.getPublishedSources('cnews')
    >>> soyuz_helper.checkPubList(all_published_main_pubs, result)
    True

Looking for all PUBLISHED or PENDING publications in main_archive and all
pockets.

    >>> all_main_pubs = [
    ...     pub_main_proposed_published,
    ...     pub_main_updates_pending,
    ...     pub_main_release_published,
    ...     pub_main_release_pending,
    ...     ]

    >>> all_main_pubs = sorted(
    ...    all_main_pubs, key=operator.attrgetter('id'), reverse=True)

    >>> result = breezy_autotest.getPublishedSources(
    ...     'cnews', include_pending=True)
    >>> soyuz_helper.checkPubList(all_main_pubs, result)
    True

Using 'pocket' filter:

    >>> updates_main_pubs = [
    ...     pub_main_updates_pending,
    ...     ]

    >>> result = breezy_autotest.getPublishedSources(
    ...     'cnews', include_pending=True,
    ...     pocket=PackagePublishingPocket.UPDATES)

    >>> soyuz_helper.checkPubList(updates_main_pubs, result)
    True

Using 'exclude_pocket' filter, to exclude publications to RELEASE pocket:

    >>> non_release_main_pubs = [
    ...     pub_main_proposed_published,
    ...     pub_main_updates_pending,
    ...     ]


    >>> non_release_main_pubs = sorted(
    ...    non_release_main_pubs, key=operator.attrgetter('id'),
    ...    reverse=True)

    >>> result = breezy_autotest.getPublishedSources(
    ...     'cnews', include_pending=True,
    ...     exclude_pocket=PackagePublishingPocket.RELEASE)

    >>> soyuz_helper.checkPubList(non_release_main_pubs, result)
    True

Looking for all PUBLISHED or PENDING publications in cprov PPA and all
pockets.

    >>> all_ppa_pubs = [
    ...     pub_ppa_proposed_published,
    ...     pub_ppa_updates_pending,
    ...     pub_ppa_release_published,
    ...     pub_ppa_release_pending,
    ...     ]

    >>> all_ppa_pubs = sorted(
    ...    all_ppa_pubs, key=operator.attrgetter('id'), reverse=True)

    >>> result = breezy_autotest.getPublishedSources(
    ...    'cnews', include_pending=True, archive=cprov_archive)
    >>> soyuz_helper.checkPubList(all_ppa_pubs, result)
    True