13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.34
by Karl Fogel
Add license header blocks to .py, .zcml, and .pt files that don't have it |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
3 |
|
4 |
"""Tests relating to the revision cache."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
7 |
||
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
8 |
from datetime import ( |
9 |
datetime, |
|
10 |
timedelta, |
|
11 |
)
|
|
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
12 |
|
8786.1.11
by Tim Penhey
date check works. |
13 |
import pytz |
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
14 |
from zope.component import getUtility |
8786.1.10
by Tim Penhey
authoredBy works. |
15 |
from zope.security.proxy import removeSecurityProxy |
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
16 |
|
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
17 |
from lp.code.interfaces.revisioncache import IRevisionCache |
18 |
from lp.code.model.revision import RevisionCache |
|
14600.2.2
by Curtis Hovey
Moved webapp to lp.services. |
19 |
from lp.services.webapp.interfaces import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
20 |
DEFAULT_FLAVOR, |
21 |
IStoreSelector, |
|
22 |
MAIN_STORE, |
|
23 |
)
|
|
24 |
from lp.testing import ( |
|
25 |
TestCaseWithFactory, |
|
26 |
time_counter, |
|
27 |
)
|
|
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
28 |
from lp.testing.layers import DatabaseFunctionalLayer |
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
29 |
|
30 |
||
8728.2.3
by Tim Penhey
Add adapters for objects to IRevisionCache. |
31 |
class TestRevisionCacheAdaptation(TestCaseWithFactory): |
32 |
"""Check that certain objects can be adapted to a revision cache."""
|
|
33 |
||
34 |
layer = DatabaseFunctionalLayer |
|
35 |
||
36 |
def test_product(self): |
|
37 |
# A product can be adapted to a revision cache.
|
|
38 |
product = self.factory.makeProduct() |
|
39 |
cache = IRevisionCache(product, None) |
|
40 |
self.assertIsNot(None, cache) |
|
41 |
||
42 |
def test_project(self): |
|
43 |
# A project can be adapted to a revision cache.
|
|
44 |
project = self.factory.makeProject() |
|
45 |
cache = IRevisionCache(project, None) |
|
46 |
self.assertIsNot(None, cache) |
|
47 |
||
48 |
def test_person(self): |
|
49 |
# A person can be adapted to a revision cache.
|
|
50 |
person = self.factory.makePerson() |
|
51 |
cache = IRevisionCache(person, None) |
|
52 |
self.assertIsNot(None, cache) |
|
53 |
||
8728.4.1
by Tim Penhey
Add the view that is used by the branch-count-summary page template and register the view against many objects. |
54 |
def test_distribution(self): |
55 |
# A distribution can be adapted to a revision cache.
|
|
56 |
distribution = self.factory.makeDistribution() |
|
57 |
cache = IRevisionCache(distribution, None) |
|
58 |
self.assertIsNot(None, cache) |
|
59 |
||
60 |
def test_distro_series(self): |
|
61 |
# A distro series can be adapted to a revision cache.
|
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
62 |
distro_series = self.factory.makeDistroSeries() |
8728.4.1
by Tim Penhey
Add the view that is used by the branch-count-summary page template and register the view against many objects. |
63 |
cache = IRevisionCache(distro_series, None) |
64 |
self.assertIsNot(None, cache) |
|
65 |
||
8728.2.3
by Tim Penhey
Add adapters for objects to IRevisionCache. |
66 |
def test_source_package(self): |
67 |
# A source package can be adapted to a revision cache.
|
|
68 |
source_package = self.factory.makeSourcePackage() |
|
69 |
cache = IRevisionCache(source_package, None) |
|
70 |
self.assertIsNot(None, cache) |
|
71 |
||
72 |
def test_distribution_source__package(self): |
|
73 |
# A distribution source pakcage can be adapted to a revision cache.
|
|
74 |
distro_source_package = self.factory.makeDistributionSourcePackage() |
|
75 |
cache = IRevisionCache(distro_source_package, None) |
|
76 |
self.assertIsNot(None, cache) |
|
77 |
||
78 |
||
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
79 |
class TestRevisionCache(TestCaseWithFactory): |
80 |
"""Test the revision cache filters and counts."""
|
|
81 |
||
82 |
layer = DatabaseFunctionalLayer |
|
8786.1.2
by Tim Penhey
Write enough to get the tests passing. |
83 |
|
8786.1.1
by Tim Penhey
Starting of tests for the revision cache. |
84 |
def test_initially_empty(self): |
85 |
# A test just to confirm that the RevisionCache is empty.
|
|
86 |
store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR) |
|
87 |
results = store.find(RevisionCache) |
|
88 |
self.assertEqual(0, results.count()) |
|
89 |
||
8786.1.3
by Tim Penhey
More tests pass. |
90 |
def makeCachedRevision(self, revision=None, product=None, |
8786.1.7
by Tim Penhey
inSourcePackage tested |
91 |
package=None, private=False): |
8786.1.2
by Tim Penhey
Write enough to get the tests passing. |
92 |
# A factory method for RevisionCache objects.
|
8786.1.3
by Tim Penhey
More tests pass. |
93 |
if revision is None: |
94 |
revision = self.factory.makeRevision() |
|
95 |
cached = RevisionCache(revision) |
|
96 |
cached.product = product |
|
8786.1.7
by Tim Penhey
inSourcePackage tested |
97 |
if package is not None: |
98 |
cached.distroseries = package.distroseries |
|
99 |
cached.sourcepackagename = package.sourcepackagename |
|
8786.1.4
by Tim Penhey
Public restriction tested. |
100 |
cached.private = private |
8786.1.5
by Tim Penhey
inProduct working. |
101 |
return revision |
8786.1.2
by Tim Penhey
Write enough to get the tests passing. |
102 |
|
103 |
def test_simple_total_count(self): |
|
104 |
# Test that the count does in fact count the revisions we add.
|
|
105 |
for i in range(4): |
|
106 |
self.makeCachedRevision() |
|
107 |
cache = getUtility(IRevisionCache) |
|
108 |
self.assertEqual(4, cache.count()) |
|
109 |
||
8786.1.12
by Tim Penhey
Added test for ordering. |
110 |
def test_revision_ordering(self): |
111 |
# Revisions are returned most recent first.
|
|
112 |
tc = time_counter( |
|
113 |
origin=datetime.now(pytz.UTC) - timedelta(days=15), |
|
114 |
delta=timedelta(days=1)) |
|
115 |
# Make four cached revisions spanning 15, 14, 13 and 12 days ago.
|
|
116 |
# Create from oldest to newest, then check that the ordering from the
|
|
117 |
# query is the reverse order.
|
|
118 |
revisions = [ |
|
119 |
self.makeCachedRevision( |
|
120 |
revision=self.factory.makeRevision(revision_date=tc.next())) |
|
121 |
for i in range(4)] |
|
122 |
revisions.reverse() |
|
123 |
cache = getUtility(IRevisionCache) |
|
124 |
self.assertEqual(revisions, list(cache.getRevisions())) |
|
125 |
||
8786.1.3
by Tim Penhey
More tests pass. |
126 |
def test_revision_in_multiple_namespaces_counted_once(self): |
127 |
# A revision that is in multiple namespaces is only counted once.
|
|
128 |
revision = self.factory.makeRevision() |
|
129 |
# Make a cached revision of a revision in a junk branch.
|
|
130 |
self.makeCachedRevision(revision) |
|
131 |
# Make the same revision appear in a product.
|
|
8786.1.7
by Tim Penhey
inSourcePackage tested |
132 |
self.makeCachedRevision(revision, product=self.factory.makeProduct()) |
8786.1.3
by Tim Penhey
More tests pass. |
133 |
# And the same revision in a source package.
|
134 |
self.makeCachedRevision( |
|
8786.1.7
by Tim Penhey
inSourcePackage tested |
135 |
revision, package=self.factory.makeSourcePackage()) |
8786.1.3
by Tim Penhey
More tests pass. |
136 |
cache = getUtility(IRevisionCache) |
137 |
self.assertEqual(1, cache.count()) |
|
138 |
||
8786.1.10
by Tim Penhey
authoredBy works. |
139 |
def test_revisions_bound_by_date(self): |
140 |
# Only revisions in the last 30 days are returned, even if the
|
|
141 |
# revision cache table hasn't been trimmed lately.
|
|
8786.1.11
by Tim Penhey
date check works. |
142 |
tc = time_counter( |
143 |
origin=datetime.now(pytz.UTC) - timedelta(days=27), |
|
144 |
delta=timedelta(days=-2)) |
|
145 |
# Make four cached revisions spanning 33, 31, 29, and 27 days ago.
|
|
146 |
for i in range(4): |
|
147 |
self.makeCachedRevision( |
|
148 |
revision=self.factory.makeRevision(revision_date=tc.next())) |
|
149 |
cache = getUtility(IRevisionCache) |
|
150 |
self.assertEqual(2, cache.count()) |
|
8786.1.10
by Tim Penhey
authoredBy works. |
151 |
|
8786.2.1
by Tim Penhey
Updates following review. |
152 |
def assertCollectionContents(self, expected_revisions, |
153 |
revision_collection): |
|
8786.1.5
by Tim Penhey
inProduct working. |
154 |
# Check that the revisions returned from the revision collection match
|
155 |
# the expected revisions.
|
|
156 |
self.assertEqual( |
|
157 |
sorted(expected_revisions), |
|
158 |
sorted(revision_collection.getRevisions())) |
|
159 |
||
8786.1.4
by Tim Penhey
Public restriction tested. |
160 |
def test_private_revisions(self): |
8786.1.21
by Tim Penhey
Other review clean ups. |
161 |
# Private flags are honoured when only requesting public revisions.
|
8786.1.4
by Tim Penhey
Public restriction tested. |
162 |
# If a revision is in both public and private branches, then there are
|
163 |
# two entried in the revision cache for it, and it will be retrieved
|
|
164 |
# in a revision query
|
|
165 |
revision = self.factory.makeRevision() |
|
166 |
# Put that revision in both a public and private branch.
|
|
167 |
self.makeCachedRevision(revision, private=False) |
|
168 |
self.makeCachedRevision(revision, private=True) |
|
169 |
# Make a random public cached revision.
|
|
8786.1.5
by Tim Penhey
inProduct working. |
170 |
public_revision = self.makeCachedRevision() |
8786.1.4
by Tim Penhey
Public restriction tested. |
171 |
# Make a private cached revision.
|
172 |
self.makeCachedRevision(private=True) |
|
173 |
||
174 |
cache = getUtility(IRevisionCache) |
|
175 |
# Counting all revisions gets public and private revisions.
|
|
176 |
self.assertEqual(3, cache.count()) |
|
177 |
# Limiting to public revisions does not get the private revisions.
|
|
178 |
self.assertEqual(2, cache.public().count()) |
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
179 |
self.assertCollectionContents( |
180 |
[revision, public_revision], cache.public()) |
|
8786.1.5
by Tim Penhey
inProduct working. |
181 |
|
182 |
def test_in_product(self): |
|
183 |
# Revisions in a particular product can be restricted using the
|
|
184 |
# inProduct method.
|
|
185 |
product = self.factory.makeProduct() |
|
186 |
rev1 = self.makeCachedRevision(product=product) |
|
187 |
rev2 = self.makeCachedRevision(product=product) |
|
188 |
# Make two other revisions, on in a different product, and another
|
|
189 |
# general one.
|
|
190 |
self.makeCachedRevision(product=self.factory.makeProduct()) |
|
191 |
self.makeCachedRevision() |
|
192 |
revision_cache = getUtility(IRevisionCache).inProduct(product) |
|
8786.2.1
by Tim Penhey
Updates following review. |
193 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.4
by Tim Penhey
Public restriction tested. |
194 |
|
8786.1.6
by Tim Penhey
inProject working |
195 |
def test_in_project(self): |
196 |
# Revisions across a project group can be determined using the
|
|
197 |
# inProject method.
|
|
198 |
project = self.factory.makeProject() |
|
199 |
product1 = self.factory.makeProduct(project=project) |
|
200 |
product2 = self.factory.makeProduct(project=project) |
|
201 |
rev1 = self.makeCachedRevision(product=product1) |
|
202 |
rev2 = self.makeCachedRevision(product=product2) |
|
203 |
# Make two other revisions, on in a different product, and another
|
|
204 |
# general one.
|
|
205 |
self.makeCachedRevision(product=self.factory.makeProduct()) |
|
206 |
self.makeCachedRevision() |
|
207 |
revision_cache = getUtility(IRevisionCache).inProject(project) |
|
8786.2.1
by Tim Penhey
Updates following review. |
208 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.7
by Tim Penhey
inSourcePackage tested |
209 |
|
210 |
def test_in_source_package(self): |
|
211 |
# Revisions associated with a particular source package are available
|
|
212 |
# using the inSourcePackage method.
|
|
213 |
sourcepackage = self.factory.makeSourcePackage() |
|
214 |
rev1 = self.makeCachedRevision(package=sourcepackage) |
|
215 |
rev2 = self.makeCachedRevision(package=sourcepackage) |
|
216 |
# Make two other revisions, on in a different product, and another
|
|
217 |
# general one.
|
|
218 |
self.makeCachedRevision(package=self.factory.makeSourcePackage()) |
|
219 |
self.makeCachedRevision() |
|
220 |
revision_cache = getUtility(IRevisionCache).inSourcePackage( |
|
221 |
sourcepackage) |
|
8786.2.1
by Tim Penhey
Updates following review. |
222 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.8
by Tim Penhey
inDistribution works.# |
223 |
|
224 |
def test_in_distribution(self): |
|
225 |
# Check inDistribution limits to those revisions associated with
|
|
226 |
# distribution series related to the distro.
|
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
227 |
distroseries1 = self.factory.makeDistroSeries() |
8786.1.8
by Tim Penhey
inDistribution works.# |
228 |
distro = distroseries1.distribution |
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
229 |
distroseries2 = self.factory.makeDistroSeries(distribution=distro) |
8786.1.8
by Tim Penhey
inDistribution works.# |
230 |
# Two revisions associated with sourcepackages in the series for the
|
231 |
# distro.
|
|
232 |
rev1 = self.makeCachedRevision( |
|
233 |
package=self.factory.makeSourcePackage( |
|
234 |
distroseries=distroseries1)) |
|
235 |
rev2 = self.makeCachedRevision( |
|
236 |
package=self.factory.makeSourcePackage( |
|
237 |
distroseries=distroseries2)) |
|
238 |
# Make two other revisions, on in a different product, and another
|
|
239 |
# general one.
|
|
240 |
self.makeCachedRevision(package=self.factory.makeSourcePackage()) |
|
241 |
self.makeCachedRevision() |
|
242 |
revision_cache = getUtility(IRevisionCache).inDistribution(distro) |
|
8786.2.1
by Tim Penhey
Updates following review. |
243 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.8
by Tim Penhey
inDistribution works.# |
244 |
|
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
245 |
def test_in_distro_series(self): |
246 |
# Check that inDistroSeries limits the revisions to those in the
|
|
247 |
# distroseries specified.
|
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
248 |
distroseries1 = self.factory.makeDistroSeries() |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
249 |
distro = distroseries1.distribution |
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
250 |
distroseries2 = self.factory.makeDistroSeries(distribution=distro) |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
251 |
# Two revisions associated with sourcepackages in the distro series we
|
252 |
# care about.
|
|
253 |
rev1 = self.makeCachedRevision( |
|
254 |
package=self.factory.makeSourcePackage( |
|
255 |
distroseries=distroseries1)) |
|
256 |
rev2 = self.makeCachedRevision( |
|
257 |
package=self.factory.makeSourcePackage( |
|
258 |
distroseries=distroseries1)) |
|
259 |
# Make some other revisions. Same distro, different series.
|
|
260 |
self.makeCachedRevision( |
|
261 |
package=self.factory.makeSourcePackage( |
|
262 |
distroseries=distroseries2)) |
|
263 |
# Different distro source package revision.
|
|
264 |
self.makeCachedRevision(package=self.factory.makeSourcePackage()) |
|
265 |
# Some other revision.
|
|
266 |
self.makeCachedRevision() |
|
267 |
revision_cache = getUtility(IRevisionCache).inDistroSeries( |
|
268 |
distroseries1) |
|
8786.2.1
by Tim Penhey
Updates following review. |
269 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
270 |
|
271 |
def test_in_distribution_source_package(self): |
|
272 |
# Check that inDistributionSourcePackage limits to revisions in
|
|
273 |
# different distro series for the same source package name.
|
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
274 |
distroseries1 = self.factory.makeDistroSeries() |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
275 |
distro = distroseries1.distribution |
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
276 |
distroseries2 = self.factory.makeDistroSeries(distribution=distro) |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
277 |
# Two revisions associated with the same sourcepackagename in the
|
278 |
# distro series we care about.
|
|
279 |
sourcepackagename = self.factory.makeSourcePackageName() |
|
280 |
rev1 = self.makeCachedRevision( |
|
281 |
package=self.factory.makeSourcePackage( |
|
282 |
distroseries=distroseries1, |
|
283 |
sourcepackagename=sourcepackagename)) |
|
284 |
rev2 = self.makeCachedRevision( |
|
285 |
package=self.factory.makeSourcePackage( |
|
286 |
distroseries=distroseries2, |
|
287 |
sourcepackagename=sourcepackagename)) |
|
288 |
# Make some other revisions. Same distroseries, different source
|
|
289 |
# package.
|
|
290 |
self.makeCachedRevision( |
|
291 |
package=self.factory.makeSourcePackage( |
|
292 |
distroseries=distroseries1)) |
|
293 |
# Different distro source package revision.
|
|
294 |
self.makeCachedRevision(package=self.factory.makeSourcePackage()) |
|
295 |
# Some other revision.
|
|
296 |
self.makeCachedRevision() |
|
297 |
dsp = self.factory.makeDistributionSourcePackage( |
|
298 |
distribution=distro, sourcepackagename=sourcepackagename) |
|
299 |
revision_cache = getUtility(IRevisionCache) |
|
300 |
revision_cache = revision_cache.inDistributionSourcePackage(dsp) |
|
8786.2.1
by Tim Penhey
Updates following review. |
301 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.9
by Tim Penhey
distroseries and distribution source packages are now filtered too. |
302 |
|
8786.1.21
by Tim Penhey
Other review clean ups. |
303 |
def makePersonAndLinkedRevision(self): |
8786.1.10
by Tim Penhey
authoredBy works. |
304 |
"""Make a person and a revision that is linked to them."""
|
8786.1.21
by Tim Penhey
Other review clean ups. |
305 |
person = self.factory.makePerson() |
306 |
revision = self.factory.makeRevision() |
|
8786.1.10
by Tim Penhey
authoredBy works. |
307 |
# Link up the revision author and person. This is normally a
|
308 |
# protected method, so remove the security proxy.
|
|
309 |
removeSecurityProxy(revision.revision_author).person = person |
|
310 |
rev = self.makeCachedRevision(revision) |
|
311 |
return person, rev |
|
312 |
||
313 |
def test_authored_by_individual(self): |
|
314 |
# Check that authoredBy appropriatly limits revisions to those
|
|
315 |
# authored by the individual specified.
|
|
8786.1.21
by Tim Penhey
Other review clean ups. |
316 |
eric, rev1 = self.makePersonAndLinkedRevision() |
8786.1.10
by Tim Penhey
authoredBy works. |
317 |
# Make a second revision by eric.
|
318 |
rev2 = self.makeCachedRevision( |
|
319 |
self.factory.makeRevision(rev1.revision_author.name)) |
|
320 |
# Other revisions have other authors.
|
|
321 |
self.makeCachedRevision() |
|
322 |
revision_cache = getUtility(IRevisionCache).authoredBy(eric) |
|
8786.2.1
by Tim Penhey
Updates following review. |
323 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.10
by Tim Penhey
authoredBy works. |
324 |
|
325 |
def test_authored_by_team(self): |
|
326 |
# Check that authoredBy appropriatly limits revisions to those
|
|
327 |
# authored by individuals of a team. Since we want to add members to
|
|
328 |
# the team, and don't want security checks, we remove the security
|
|
329 |
# proxy from the team.
|
|
330 |
team = removeSecurityProxy(self.factory.makeTeam()) |
|
8786.1.21
by Tim Penhey
Other review clean ups. |
331 |
eric, rev1 = self.makePersonAndLinkedRevision() |
8786.1.10
by Tim Penhey
authoredBy works. |
332 |
team.addMember(eric, team.teamowner) |
333 |
# Now make another revision by someone else in the team.
|
|
8786.1.21
by Tim Penhey
Other review clean ups. |
334 |
bob, rev2 = self.makePersonAndLinkedRevision() |
8786.1.10
by Tim Penhey
authoredBy works. |
335 |
team.addMember(bob, team.teamowner) |
336 |
# Other revisions have other authors.
|
|
337 |
self.makeCachedRevision() |
|
338 |
revision_cache = getUtility(IRevisionCache).authoredBy(team) |
|
8786.2.1
by Tim Penhey
Updates following review. |
339 |
self.assertCollectionContents([rev1, rev2], revision_cache) |
8786.1.10
by Tim Penhey
authoredBy works. |
340 |
|
8786.1.16
by Tim Penhey
Add in authorCount. |
341 |
def test_author_count(self): |
342 |
# The author count should count distinct revision authors. Revision
|
|
343 |
# authors linked to launchpad people use the person id as the
|
|
344 |
# discriminator.
|
|
345 |
||
346 |
# Make two revisions not assigned to anyone, then two revisions with
|
|
347 |
# different revision names linked to the same person.
|
|
348 |
revisions = [ |
|
349 |
self.makeCachedRevision(revision=self.factory.makeRevision()) |
|
350 |
for i in range(4)] |
|
351 |
# Make revisions [2] and [3] linked to the same person.
|
|
352 |
person = self.factory.makePerson() |
|
353 |
removeSecurityProxy(revisions[2].revision_author).person = person |
|
354 |
removeSecurityProxy(revisions[3].revision_author).person = person |
|
355 |
revision_cache = getUtility(IRevisionCache) |
|
356 |
self.assertEqual(3, revision_cache.authorCount()) |
|
357 |
||
8786.1.22
by Tim Penhey
New test for non-linked revision authors. |
358 |
def test_author_count_distinct(self): |
359 |
# If there are multiple revisions with the same revision author text,
|
|
360 |
# but not linked to a Launchpad person, then that revision_text is
|
|
361 |
# counted as one author.
|
|
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
362 |
for counter in xrange(4): |
8786.1.22
by Tim Penhey
New test for non-linked revision authors. |
363 |
self.makeCachedRevision(revision=self.factory.makeRevision( |
13597.1.1
by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint. |
364 |
author="Foo <foo@example.com>")) |
8786.1.22
by Tim Penhey
New test for non-linked revision authors. |
365 |
revision_cache = getUtility(IRevisionCache) |
366 |
self.assertEqual(1, revision_cache.authorCount()) |