Merge ~cjwatson/launchpad:version-lookup-as-text into launchpad:master
- Git
- lp:~cjwatson/launchpad
- version-lookup-as-text
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 609e834528f76747ca4e8ea7b2121451e74c611c |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:version-lookup-as-text |
Merge into: | launchpad:master |
Prerequisite: | ~cjwatson/launchpad:db-xpr-version-text |
Diff against target: |
368 lines (+114/-28) 10 files modified
lib/lp/registry/model/distributionsourcepackage.py (+1/-1) lib/lp/registry/model/distroseriesdifference.py (+2/-1) lib/lp/registry/model/sourcepackage.py (+4/-16) lib/lp/registry/tests/test_distributionsourcepackage.py (+19/-1) lib/lp/soyuz/model/archive.py (+7/-4) lib/lp/soyuz/model/distroarchseriesbinarypackage.py (+2/-1) lib/lp/soyuz/model/publishing.py (+2/-1) lib/lp/soyuz/model/queue.py (+2/-1) lib/lp/soyuz/scripts/gina/handlers.py (+2/-2) lib/lp/soyuz/tests/test_archive.py (+73/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+389597@code.launchpad.net |
Commit message
Match source/binary versions as exact strings
Description of the change
There is one case in the primary archive of a package (libapache-
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/lp/registry/model/distributionsourcepackage.py b/lib/lp/registry/model/distributionsourcepackage.py | |||
2 | index 9e40f02..da4a021 100644 | |||
3 | --- a/lib/lp/registry/model/distributionsourcepackage.py | |||
4 | +++ b/lib/lp/registry/model/distributionsourcepackage.py | |||
5 | @@ -261,7 +261,7 @@ class DistributionSourcePackage(BugTargetBase, | |||
6 | 261 | SourcePackageRelease.id AND | 261 | SourcePackageRelease.id AND |
7 | 262 | SourcePackagePublishingHistory.sourcepackagename = %s AND | 262 | SourcePackagePublishingHistory.sourcepackagename = %s AND |
8 | 263 | SourcePackageRelease.sourcepackagename = %s AND | 263 | SourcePackageRelease.sourcepackagename = %s AND |
10 | 264 | SourcePackageRelease.version = %s | 264 | SourcePackageRelease.version::text = %s |
11 | 265 | """ % sqlvalues(self.distribution, | 265 | """ % sqlvalues(self.distribution, |
12 | 266 | self.distribution.all_distro_archive_ids, | 266 | self.distribution.all_distro_archive_ids, |
13 | 267 | self.sourcepackagename, | 267 | self.sourcepackagename, |
14 | diff --git a/lib/lp/registry/model/distroseriesdifference.py b/lib/lp/registry/model/distroseriesdifference.py | |||
15 | index 1735ea6..3cdcd16 100644 | |||
16 | --- a/lib/lp/registry/model/distroseriesdifference.py | |||
17 | +++ b/lib/lp/registry/model/distroseriesdifference.py | |||
18 | @@ -23,6 +23,7 @@ import six | |||
19 | 23 | from sqlobject import StringCol | 23 | from sqlobject import StringCol |
20 | 24 | from storm.expr import ( | 24 | from storm.expr import ( |
21 | 25 | And, | 25 | And, |
22 | 26 | Cast, | ||
23 | 26 | Column, | 27 | Column, |
24 | 27 | Desc, | 28 | Desc, |
25 | 28 | Or, | 29 | Or, |
26 | @@ -147,7 +148,7 @@ def most_recent_publications(dsds, in_parent, statuses, match_version=False): | |||
27 | 147 | conditions, | 148 | conditions, |
28 | 148 | SourcePackageRelease.id == | 149 | SourcePackageRelease.id == |
29 | 149 | SourcePackagePublishingHistory.sourcepackagereleaseID, | 150 | SourcePackagePublishingHistory.sourcepackagereleaseID, |
31 | 150 | SourcePackageRelease.version == version_col, | 151 | Cast(SourcePackageRelease.version, "text") == version_col, |
32 | 151 | ) | 152 | ) |
33 | 152 | # The sort order is critical so that the DISTINCT ON clause selects the | 153 | # The sort order is critical so that the DISTINCT ON clause selects the |
34 | 153 | # most recent publication (i.e. the one with the highest id). | 154 | # most recent publication (i.e. the one with the highest id). |
35 | diff --git a/lib/lp/registry/model/sourcepackage.py b/lib/lp/registry/model/sourcepackage.py | |||
36 | index 42da907..9e40417 100644 | |||
37 | --- a/lib/lp/registry/model/sourcepackage.py | |||
38 | +++ b/lib/lp/registry/model/sourcepackage.py | |||
39 | @@ -217,12 +217,11 @@ class SourcePackage(BugTargetBase, HasCodeImportsMixin, | |||
40 | 217 | return '<%s %r %r %r>' % (self.__class__.__name__, | 217 | return '<%s %r %r %r>' % (self.__class__.__name__, |
41 | 218 | self.distribution, self.distroseries, self.sourcepackagename) | 218 | self.distribution, self.distroseries, self.sourcepackagename) |
42 | 219 | 219 | ||
45 | 220 | def _getPublishingHistory(self, version=None, include_status=None, | 220 | def _getPublishingHistory(self, include_status=None, order_by=None): |
44 | 221 | exclude_status=None, order_by=None): | ||
46 | 222 | """Build a query and return a list of SourcePackagePublishingHistory. | 221 | """Build a query and return a list of SourcePackagePublishingHistory. |
47 | 223 | 222 | ||
48 | 224 | This is mainly a helper function for this class so that code is | 223 | This is mainly a helper function for this class so that code is |
50 | 225 | not duplicated. include_status and exclude_status must be a sequence. | 224 | not duplicated. include_status must be a sequence. |
51 | 226 | """ | 225 | """ |
52 | 227 | clauses = [] | 226 | clauses = [] |
53 | 228 | clauses.append( | 227 | clauses.append( |
54 | @@ -235,9 +234,6 @@ class SourcePackage(BugTargetBase, HasCodeImportsMixin, | |||
55 | 235 | self.sourcepackagename, | 234 | self.sourcepackagename, |
56 | 236 | self.distroseries, | 235 | self.distroseries, |
57 | 237 | self.distribution.all_distro_archive_ids)) | 236 | self.distribution.all_distro_archive_ids)) |
58 | 238 | if version: | ||
59 | 239 | clauses.append( | ||
60 | 240 | "SourcePackageRelease.version = %s" % sqlvalues(version)) | ||
61 | 241 | 237 | ||
62 | 242 | if include_status: | 238 | if include_status: |
63 | 243 | if not isinstance(include_status, list): | 239 | if not isinstance(include_status, list): |
64 | @@ -245,12 +241,6 @@ class SourcePackage(BugTargetBase, HasCodeImportsMixin, | |||
65 | 245 | clauses.append("SourcePackagePublishingHistory.status IN %s" | 241 | clauses.append("SourcePackagePublishingHistory.status IN %s" |
66 | 246 | % sqlvalues(include_status)) | 242 | % sqlvalues(include_status)) |
67 | 247 | 243 | ||
68 | 248 | if exclude_status: | ||
69 | 249 | if not isinstance(exclude_status, list): | ||
70 | 250 | exclude_status = list(exclude_status) | ||
71 | 251 | clauses.append("SourcePackagePublishingHistory.status NOT IN %s" | ||
72 | 252 | % sqlvalues(exclude_status)) | ||
73 | 253 | |||
74 | 254 | query = " AND ".join(clauses) | 244 | query = " AND ".join(clauses) |
75 | 255 | 245 | ||
76 | 256 | if not order_by: | 246 | if not order_by: |
77 | @@ -260,12 +250,10 @@ class SourcePackage(BugTargetBase, HasCodeImportsMixin, | |||
78 | 260 | query, orderBy=order_by, clauseTables=['SourcePackageRelease'], | 250 | query, orderBy=order_by, clauseTables=['SourcePackageRelease'], |
79 | 261 | prejoinClauseTables=['SourcePackageRelease']) | 251 | prejoinClauseTables=['SourcePackageRelease']) |
80 | 262 | 252 | ||
83 | 263 | def _getFirstPublishingHistory(self, version=None, include_status=None, | 253 | def _getFirstPublishingHistory(self, include_status=None, order_by=None): |
82 | 264 | exclude_status=None, order_by=None): | ||
84 | 265 | """As _getPublishingHistory, but just returns the first item.""" | 254 | """As _getPublishingHistory, but just returns the first item.""" |
85 | 266 | try: | 255 | try: |
88 | 267 | package = self._getPublishingHistory( | 256 | package = self._getPublishingHistory(include_status, order_by)[0] |
87 | 268 | version, include_status, exclude_status, order_by)[0] | ||
89 | 269 | except IndexError: | 257 | except IndexError: |
90 | 270 | return None | 258 | return None |
91 | 271 | else: | 259 | else: |
92 | diff --git a/lib/lp/registry/tests/test_distributionsourcepackage.py b/lib/lp/registry/tests/test_distributionsourcepackage.py | |||
93 | index 15da65e..677d080 100644 | |||
94 | --- a/lib/lp/registry/tests/test_distributionsourcepackage.py | |||
95 | +++ b/lib/lp/registry/tests/test_distributionsourcepackage.py | |||
96 | @@ -6,7 +6,10 @@ | |||
97 | 6 | __metaclass__ = type | 6 | __metaclass__ = type |
98 | 7 | 7 | ||
99 | 8 | from storm.store import Store | 8 | from storm.store import Store |
101 | 9 | from testtools.matchers import Equals | 9 | from testtools.matchers import ( |
102 | 10 | Equals, | ||
103 | 11 | MatchesStructure, | ||
104 | 12 | ) | ||
105 | 10 | import transaction | 13 | import transaction |
106 | 11 | from zope.component import getUtility | 14 | from zope.component import getUtility |
107 | 12 | from zope.security.proxy import removeSecurityProxy | 15 | from zope.security.proxy import removeSecurityProxy |
108 | @@ -165,6 +168,21 @@ class TestDistributionSourcePackage(TestCaseWithFactory): | |||
109 | 165 | driver = distribution.drivers[0] | 168 | driver = distribution.drivers[0] |
110 | 166 | self.assertTrue(dsp.personHasDriverRights(driver)) | 169 | self.assertTrue(dsp.personHasDriverRights(driver)) |
111 | 167 | 170 | ||
112 | 171 | def test_getVersion_matches_version_as_text(self): | ||
113 | 172 | # Versions such as 0.7-4 and 0.07-4 are equal according to the | ||
114 | 173 | # "debversion" type, but for lookup purposes we compare the text of | ||
115 | 174 | # the version strings exactly. | ||
116 | 175 | distribution = self.factory.makeDistribution() | ||
117 | 176 | dsp = self.factory.makeDistributionSourcePackage( | ||
118 | 177 | distribution=distribution) | ||
119 | 178 | spph = self.factory.makeSourcePackagePublishingHistory( | ||
120 | 179 | archive=distribution.main_archive, | ||
121 | 180 | sourcepackagename=dsp.sourcepackagename, version="0.7-4") | ||
122 | 181 | self.assertThat(dsp.getVersion("0.7-4"), MatchesStructure.byEquality( | ||
123 | 182 | distribution=distribution, | ||
124 | 183 | sourcepackagerelease=spph.sourcepackagerelease)) | ||
125 | 184 | self.assertIsNone(dsp.getVersion("0.07-4")) | ||
126 | 185 | |||
127 | 168 | 186 | ||
128 | 169 | class TestDistributionSourcePackageFindRelatedArchives(TestCaseWithFactory): | 187 | class TestDistributionSourcePackageFindRelatedArchives(TestCaseWithFactory): |
129 | 170 | 188 | ||
130 | diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py | |||
131 | index f5f711b..3217e1d 100644 | |||
132 | --- a/lib/lp/soyuz/model/archive.py | |||
133 | +++ b/lib/lp/soyuz/model/archive.py | |||
134 | @@ -26,6 +26,7 @@ from sqlobject import ( | |||
135 | 26 | from storm.base import Storm | 26 | from storm.base import Storm |
136 | 27 | from storm.expr import ( | 27 | from storm.expr import ( |
137 | 28 | And, | 28 | And, |
138 | 29 | Cast, | ||
139 | 29 | Count, | 30 | Count, |
140 | 30 | Desc, | 31 | Desc, |
141 | 31 | Join, | 32 | Join, |
142 | @@ -656,7 +657,8 @@ class Archive(SQLBase): | |||
143 | 656 | raise VersionRequiresName( | 657 | raise VersionRequiresName( |
144 | 657 | "The 'version' parameter can be used only together with" | 658 | "The 'version' parameter can be used only together with" |
145 | 658 | " the 'name' parameter.") | 659 | " the 'name' parameter.") |
147 | 659 | clauses.append(SourcePackageRelease.version == version) | 660 | clauses.append( |
148 | 661 | Cast(SourcePackageRelease.version, "text") == version) | ||
149 | 660 | elif not order_by_date: | 662 | elif not order_by_date: |
150 | 661 | order_by.insert(1, Desc(SourcePackageRelease.version)) | 663 | order_by.insert(1, Desc(SourcePackageRelease.version)) |
151 | 662 | 664 | ||
152 | @@ -854,7 +856,8 @@ class Archive(SQLBase): | |||
153 | 854 | "The 'version' parameter can be used only together with" | 856 | "The 'version' parameter can be used only together with" |
154 | 855 | " the 'name' parameter.") | 857 | " the 'name' parameter.") |
155 | 856 | 858 | ||
157 | 857 | clauses.append(BinaryPackageRelease.version == version) | 859 | clauses.append( |
158 | 860 | Cast(BinaryPackageRelease.version, "text") == version) | ||
159 | 858 | elif ordered: | 861 | elif ordered: |
160 | 859 | order_by.insert(1, Desc(BinaryPackageRelease.version)) | 862 | order_by.insert(1, Desc(BinaryPackageRelease.version)) |
161 | 860 | 863 | ||
162 | @@ -1726,7 +1729,7 @@ class Archive(SQLBase): | |||
163 | 1726 | SourcePackageRelease.id, | 1729 | SourcePackageRelease.id, |
164 | 1727 | SourcePackageRelease.sourcepackagename == SourcePackageName.id, | 1730 | SourcePackageRelease.sourcepackagename == SourcePackageName.id, |
165 | 1728 | SourcePackageName.name == name, | 1731 | SourcePackageName.name == name, |
167 | 1729 | SourcePackageRelease.version == version, | 1732 | Cast(SourcePackageRelease.version, "text") == version, |
168 | 1730 | SourcePackageRelease.id == | 1733 | SourcePackageRelease.id == |
169 | 1731 | SourcePackageReleaseFile.sourcepackagereleaseID, | 1734 | SourcePackageReleaseFile.sourcepackagereleaseID, |
170 | 1732 | SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, | 1735 | SourcePackageReleaseFile.libraryfileID == LibraryFileAlias.id, |
171 | @@ -1750,7 +1753,7 @@ class Archive(SQLBase): | |||
172 | 1750 | BinaryPackagePublishingHistory.binarypackagename == name, | 1753 | BinaryPackagePublishingHistory.binarypackagename == name, |
173 | 1751 | BinaryPackagePublishingHistory.binarypackagereleaseID == | 1754 | BinaryPackagePublishingHistory.binarypackagereleaseID == |
174 | 1752 | BinaryPackageRelease.id, | 1755 | BinaryPackageRelease.id, |
176 | 1753 | BinaryPackageRelease.version == version, | 1756 | Cast(BinaryPackageRelease.version, "text") == version, |
177 | 1754 | BinaryPackageBuild.id == BinaryPackageRelease.buildID, | 1757 | BinaryPackageBuild.id == BinaryPackageRelease.buildID, |
178 | 1755 | DistroArchSeries.id == BinaryPackageBuild.distro_arch_series_id, | 1758 | DistroArchSeries.id == BinaryPackageBuild.distro_arch_series_id, |
179 | 1756 | DistroArchSeries.architecturetag == archtag, | 1759 | DistroArchSeries.architecturetag == archtag, |
180 | diff --git a/lib/lp/soyuz/model/distroarchseriesbinarypackage.py b/lib/lp/soyuz/model/distroarchseriesbinarypackage.py | |||
181 | index 180a874..a2a92f5 100644 | |||
182 | --- a/lib/lp/soyuz/model/distroarchseriesbinarypackage.py | |||
183 | +++ b/lib/lp/soyuz/model/distroarchseriesbinarypackage.py | |||
184 | @@ -9,6 +9,7 @@ __all__ = [ | |||
185 | 9 | 'DistroArchSeriesBinaryPackage', | 9 | 'DistroArchSeriesBinaryPackage', |
186 | 10 | ] | 10 | ] |
187 | 11 | 11 | ||
188 | 12 | from storm.expr import Cast | ||
189 | 12 | from storm.locals import Desc | 13 | from storm.locals import Desc |
190 | 13 | from zope.interface import implementer | 14 | from zope.interface import implementer |
191 | 14 | 15 | ||
192 | @@ -120,7 +121,7 @@ class DistroArchSeriesBinaryPackage: | |||
193 | 120 | """See IDistroArchSeriesBinaryPackage.""" | 121 | """See IDistroArchSeriesBinaryPackage.""" |
194 | 121 | bpph = IStore(BinaryPackagePublishingHistory).find( | 122 | bpph = IStore(BinaryPackagePublishingHistory).find( |
195 | 122 | BinaryPackagePublishingHistory, | 123 | BinaryPackagePublishingHistory, |
197 | 123 | BinaryPackageRelease.version == version, | 124 | Cast(BinaryPackageRelease.version, "text") == version, |
198 | 124 | *self._getPublicationJoins() | 125 | *self._getPublicationJoins() |
199 | 125 | ).order_by(Desc(BinaryPackagePublishingHistory.datecreated) | 126 | ).order_by(Desc(BinaryPackagePublishingHistory.datecreated) |
200 | 126 | ).first() | 127 | ).first() |
201 | diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py | |||
202 | index 5e6173a..52ffae4 100644 | |||
203 | --- a/lib/lp/soyuz/model/publishing.py | |||
204 | +++ b/lib/lp/soyuz/model/publishing.py | |||
205 | @@ -30,6 +30,7 @@ from sqlobject import ( | |||
206 | 30 | ) | 30 | ) |
207 | 31 | from storm.expr import ( | 31 | from storm.expr import ( |
208 | 32 | And, | 32 | And, |
209 | 33 | Cast, | ||
210 | 33 | Desc, | 34 | Desc, |
211 | 34 | Join, | 35 | Join, |
212 | 35 | LeftJoin, | 36 | LeftJoin, |
213 | @@ -1061,7 +1062,7 @@ class PublishingSet: | |||
214 | 1061 | BinaryPackagePublishingHistory.distroarchseriesID == das.id, | 1062 | BinaryPackagePublishingHistory.distroarchseriesID == das.id, |
215 | 1062 | BinaryPackagePublishingHistory.binarypackagenameID == | 1063 | BinaryPackagePublishingHistory.binarypackagenameID == |
216 | 1063 | bpr.binarypackagenameID, | 1064 | bpr.binarypackagenameID, |
218 | 1064 | BinaryPackageRelease.version == bpr.version, | 1065 | Cast(BinaryPackageRelease.version, "text") == bpr.version, |
219 | 1065 | ) | 1066 | ) |
220 | 1066 | 1067 | ||
221 | 1067 | candidates = ( | 1068 | candidates = ( |
222 | diff --git a/lib/lp/soyuz/model/queue.py b/lib/lp/soyuz/model/queue.py | |||
223 | index 82e02a9..6465bd8 100644 | |||
224 | --- a/lib/lp/soyuz/model/queue.py | |||
225 | +++ b/lib/lp/soyuz/model/queue.py | |||
226 | @@ -23,6 +23,7 @@ from sqlobject import ( | |||
227 | 23 | SQLObjectNotFound, | 23 | SQLObjectNotFound, |
228 | 24 | StringCol, | 24 | StringCol, |
229 | 25 | ) | 25 | ) |
230 | 26 | from storm.expr import Cast | ||
231 | 26 | from storm.locals import ( | 27 | from storm.locals import ( |
232 | 27 | And, | 28 | And, |
233 | 28 | Desc, | 29 | Desc, |
234 | @@ -1487,7 +1488,7 @@ class PackageUploadSet: | |||
235 | 1487 | PackageUpload.status.is_in(approved_status), | 1488 | PackageUpload.status.is_in(approved_status), |
236 | 1488 | PackageUpload.archive == archive, | 1489 | PackageUpload.archive == archive, |
237 | 1489 | DistroSeries.distribution == distribution, | 1490 | DistroSeries.distribution == distribution, |
239 | 1490 | SourcePackageRelease.version == version, | 1491 | Cast(SourcePackageRelease.version, "text") == version, |
240 | 1491 | SourcePackageName.name == name) | 1492 | SourcePackageName.name == name) |
241 | 1492 | 1493 | ||
242 | 1493 | return conflicts.one() | 1494 | return conflicts.one() |
243 | diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py | |||
244 | index 597e5aa..99c8166 100644 | |||
245 | --- a/lib/lp/soyuz/scripts/gina/handlers.py | |||
246 | +++ b/lib/lp/soyuz/scripts/gina/handlers.py | |||
247 | @@ -560,7 +560,7 @@ class SourcePackageHandler: | |||
248 | 560 | # the distribution, no matter what status. | 560 | # the distribution, no matter what status. |
249 | 561 | query = """ | 561 | query = """ |
250 | 562 | SourcePackageRelease.sourcepackagename = %s AND | 562 | SourcePackageRelease.sourcepackagename = %s AND |
252 | 563 | SourcePackageRelease.version = %s AND | 563 | SourcePackageRelease.version::text = %s AND |
253 | 564 | SourcePackagePublishingHistory.sourcepackagerelease = | 564 | SourcePackagePublishingHistory.sourcepackagerelease = |
254 | 565 | SourcePackageRelease.id AND | 565 | SourcePackageRelease.id AND |
255 | 566 | SourcePackagePublishingHistory.distroseries = | 566 | SourcePackagePublishingHistory.distroseries = |
256 | @@ -762,7 +762,7 @@ class BinaryPackageHandler: | |||
257 | 762 | "BinaryPackageRelease.id =" | 762 | "BinaryPackageRelease.id =" |
258 | 763 | " BinaryPackagePublishingHistory.binarypackagerelease AND " | 763 | " BinaryPackagePublishingHistory.binarypackagerelease AND " |
259 | 764 | "BinaryPackageRelease.binarypackagename=%s AND " | 764 | "BinaryPackageRelease.binarypackagename=%s AND " |
261 | 765 | "BinaryPackageRelease.version=%s AND " | 765 | "BinaryPackageRelease.version::text = %s AND " |
262 | 766 | "BinaryPackageRelease.build = BinaryPackageBuild.id AND " | 766 | "BinaryPackageRelease.build = BinaryPackageBuild.id AND " |
263 | 767 | "BinaryPackageBuild.distro_arch_series = DistroArchSeries.id AND " | 767 | "BinaryPackageBuild.distro_arch_series = DistroArchSeries.id AND " |
264 | 768 | "DistroArchSeries.distroseries = DistroSeries.id AND " | 768 | "DistroArchSeries.distroseries = DistroSeries.id AND " |
265 | diff --git a/lib/lp/soyuz/tests/test_archive.py b/lib/lp/soyuz/tests/test_archive.py | |||
266 | index b015953..91acf53 100644 | |||
267 | --- a/lib/lp/soyuz/tests/test_archive.py | |||
268 | +++ b/lib/lp/soyuz/tests/test_archive.py | |||
269 | @@ -1565,6 +1565,23 @@ class TestGetBinaryPackageRelease(TestCaseWithFactory): | |||
270 | 1565 | self.factory.makeArchive().getBinaryPackageRelease( | 1565 | self.factory.makeArchive().getBinaryPackageRelease( |
271 | 1566 | self.bpns['foo-bin'], '1.2.3-4', 'i386')) | 1566 | self.bpns['foo-bin'], '1.2.3-4', 'i386')) |
272 | 1567 | 1567 | ||
273 | 1568 | def test_matches_version_as_text(self): | ||
274 | 1569 | # Versions such as 1.2.3-4 and 1.02.003-4 are equal according to the | ||
275 | 1570 | # "debversion" type, but for lookup purposes we compare the text of | ||
276 | 1571 | # the version strings exactly. | ||
277 | 1572 | other_i386_pub, other_hppa_pub = self.publisher.getPubBinaries( | ||
278 | 1573 | version='1.02.003-4', archive=self.archive, binaryname='foo-bin', | ||
279 | 1574 | status=PackagePublishingStatus.PUBLISHED, | ||
280 | 1575 | architecturespecific=True) | ||
281 | 1576 | self.assertEqual( | ||
282 | 1577 | self.i386_pub.binarypackagerelease, | ||
283 | 1578 | self.archive.getBinaryPackageRelease( | ||
284 | 1579 | self.bpns['foo-bin'], '1.2.3-4', 'i386')) | ||
285 | 1580 | self.assertEqual( | ||
286 | 1581 | other_i386_pub.binarypackagerelease, | ||
287 | 1582 | self.archive.getBinaryPackageRelease( | ||
288 | 1583 | self.bpns['foo-bin'], '1.02.003-4', 'i386')) | ||
289 | 1584 | |||
290 | 1568 | 1585 | ||
291 | 1569 | class TestGetBinaryPackageReleaseByFileName(TestCaseWithFactory): | 1586 | class TestGetBinaryPackageReleaseByFileName(TestCaseWithFactory): |
292 | 1570 | """Ensure that getBinaryPackageReleaseByFileName works as expected.""" | 1587 | """Ensure that getBinaryPackageReleaseByFileName works as expected.""" |
293 | @@ -2594,6 +2611,28 @@ class TestGetSourceFileByName(TestCaseWithFactory): | |||
294 | 2594 | pub2.source_package_name, pub2.source_package_version, | 2611 | pub2.source_package_name, pub2.source_package_version, |
295 | 2595 | dsc2.filename)) | 2612 | dsc2.filename)) |
296 | 2596 | 2613 | ||
297 | 2614 | def test_matches_version_as_text(self): | ||
298 | 2615 | # Versions such as 0.7-4 and 0.7-04 are equal according to the | ||
299 | 2616 | # "debversion" type, but for lookup purposes we compare the text of | ||
300 | 2617 | # the version strings exactly. | ||
301 | 2618 | pub = self.factory.makeSourcePackagePublishingHistory( | ||
302 | 2619 | archive=self.archive, version='0.7-4') | ||
303 | 2620 | orig = self.factory.makeLibraryFileAlias( | ||
304 | 2621 | filename='foo_0.7.orig.tar.gz') | ||
305 | 2622 | pub.sourcepackagerelease.addFile(orig) | ||
306 | 2623 | pub2 = self.factory.makeSourcePackagePublishingHistory( | ||
307 | 2624 | archive=self.archive, sourcepackagename=pub.sourcepackagename.name, | ||
308 | 2625 | version='0.7-04') | ||
309 | 2626 | orig2 = self.factory.makeLibraryFileAlias( | ||
310 | 2627 | filename='foo_0.7.orig.tar.gz') | ||
311 | 2628 | pub2.sourcepackagerelease.addFile(orig2) | ||
312 | 2629 | self.assertEqual( | ||
313 | 2630 | orig, self.archive.getSourceFileByName( | ||
314 | 2631 | pub.sourcepackagename.name, '0.7-4', orig.filename)) | ||
315 | 2632 | self.assertEqual( | ||
316 | 2633 | orig2, self.archive.getSourceFileByName( | ||
317 | 2634 | pub.sourcepackagename.name, '0.7-04', orig2.filename)) | ||
318 | 2635 | |||
319 | 2597 | 2636 | ||
320 | 2598 | class TestGetPublishedSources(TestCaseWithFactory): | 2637 | class TestGetPublishedSources(TestCaseWithFactory): |
321 | 2599 | 2638 | ||
322 | @@ -2744,6 +2783,22 @@ class TestGetPublishedSources(TestCaseWithFactory): | |||
323 | 2744 | [pubs[i] for i in (3, 2, 1, 0, 4)], | 2783 | [pubs[i] for i in (3, 2, 1, 0, 4)], |
324 | 2745 | list(archive.getPublishedSources(order_by_date=True))) | 2784 | list(archive.getPublishedSources(order_by_date=True))) |
325 | 2746 | 2785 | ||
326 | 2786 | def test_matches_version_as_text(self): | ||
327 | 2787 | # Versions such as 0.7-4 and 0.07-4 are equal according to the | ||
328 | 2788 | # "debversion" type, but for lookup purposes we compare the text of | ||
329 | 2789 | # the version strings exactly. | ||
330 | 2790 | archive = self.factory.makeArchive() | ||
331 | 2791 | pub = self.factory.makeSourcePackagePublishingHistory( | ||
332 | 2792 | archive=archive, version='0.7-4') | ||
333 | 2793 | self.assertEqual( | ||
334 | 2794 | [pub], list(archive.getPublishedSources( | ||
335 | 2795 | name=pub.sourcepackagename.name, version='0.7-4', | ||
336 | 2796 | exact_match=True))) | ||
337 | 2797 | self.assertEqual( | ||
338 | 2798 | [], list(archive.getPublishedSources( | ||
339 | 2799 | name=pub.sourcepackagename.name, version='0.07-4', | ||
340 | 2800 | exact_match=True))) | ||
341 | 2801 | |||
342 | 2747 | 2802 | ||
343 | 2748 | class TestGetPublishedSourcesWebService(TestCaseWithFactory): | 2803 | class TestGetPublishedSourcesWebService(TestCaseWithFactory): |
344 | 2749 | 2804 | ||
345 | @@ -3499,6 +3554,24 @@ class TestgetAllPublishedBinaries(TestCaseWithFactory): | |||
346 | 3499 | [pubs[i] for i in (3, 2, 1, 0, 4)], | 3554 | [pubs[i] for i in (3, 2, 1, 0, 4)], |
347 | 3500 | list(archive.getAllPublishedBinaries(order_by_date=True))) | 3555 | list(archive.getAllPublishedBinaries(order_by_date=True))) |
348 | 3501 | 3556 | ||
349 | 3557 | def test_matches_version_as_text(self): | ||
350 | 3558 | # Versions such as 0.7-4 and 0.07-4 are equal according to the | ||
351 | 3559 | # "debversion" type, but for lookup purposes we compare the text of | ||
352 | 3560 | # the version strings exactly. | ||
353 | 3561 | archive = self.factory.makeArchive() | ||
354 | 3562 | pub = self.factory.makeBinaryPackagePublishingHistory( | ||
355 | 3563 | archive=archive, version='0.7-4') | ||
356 | 3564 | self.assertEqual( | ||
357 | 3565 | [pub], | ||
358 | 3566 | list(archive.getAllPublishedBinaries( | ||
359 | 3567 | name=pub.binarypackagename.name, version='0.7-4', | ||
360 | 3568 | exact_match=True))) | ||
361 | 3569 | self.assertEqual( | ||
362 | 3570 | [], | ||
363 | 3571 | list(archive.getAllPublishedBinaries( | ||
364 | 3572 | name=pub.binarypackagename.name, version='0.07-4', | ||
365 | 3573 | exact_match=True))) | ||
366 | 3574 | |||
367 | 3502 | 3575 | ||
368 | 3503 | class TestRemovingPermissions(TestCaseWithFactory): | 3576 | class TestRemovingPermissions(TestCaseWithFactory): |
369 | 3504 | 3577 |
nice set of tests as usual.