Merge lp:~james-w/linaro-image-tools/architecture-support into lp:linaro-image-tools/11.11

Proposed by James Westby
Status: Superseded
Proposed branch: lp:~james-w/linaro-image-tools/architecture-support
Merge into: lp:linaro-image-tools/11.11
Prerequisite: lp:~james-w/linaro-image-tools/add-packages-to-hwpack
Diff against target: 596 lines (+181/-70)
5 files modified
hwpack/hardwarepack.py (+4/-2)
hwpack/packages.py (+34/-10)
hwpack/testing.py (+39/-3)
hwpack/tests/test_hardwarepack.py (+30/-19)
hwpack/tests/test_packages.py (+74/-36)
To merge this branch: bzr merge lp:~james-w/linaro-image-tools/architecture-support
Reviewer Review Type Date Requested Status
Linaro Infrastructure Pending
Review via email: mp+34377@code.launchpad.net

This proposal has been superseded by a proposal from 2010-09-02.

Description of the change

Hi,

Here's a rather simple branch to add architecture support through the code
we have now.

I just updated the spec to state that ARCHITECTURE is a required field in
the metadata, so that's now a required argument to the constructor of the
corresponding class, and it is output in the __str__ method.

Also the Package classes get architecture as an ivar, such that we can
track which architecture they are for, which leads to the change in the
get_packages_file function, which can now stop hardcoding "all".

The dummy test package object defaults to "all" as that way the tests
will work on multiple architectures without updating.

However, that leaves a gap, so I added a couple of new tests to ensure
that we fetch packages from the right architecture.

In order to support cross-build of hardware packs I stole a trick from
the chdist tool, which allows us to tell apt to pretend it is on a
different architecture. I added a test to peek inside the implementation
and check we were writing the config correctly, but the two added tests
check that it has the desired effect.

There's still a gap, as noted in the spec, about how we specify the
architectures to build for, as I'm not sure whether it should be in
the configuration file or on the command line, or some combination
of the two. This will mainly depend on how we want to hook it in to
lexbuilder I think. At least now all the infrastructure is in place
to build for any arch that we like.

Thanks,

James

To post a comment you must log in.
102. By James Westby

Merge add-packages-to-hwpack.

103. By James Westby

Merged add-packages-to-hwpack into architecture-support.

104. By James Westby

Use the new name of AptSourceFixture.

105. By James Westby

Merge add-packages-to-hwpack in to architecture-support.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hwpack/hardwarepack.py'
2--- hwpack/hardwarepack.py 2010-09-02 18:58:01 +0000
3+++ hwpack/hardwarepack.py 2010-09-02 18:58:01 +0000
4@@ -26,8 +26,8 @@
5 :type support: str or None
6 """
7
8- def __init__(self, name, version, origin=None, maintainer=None,
9- support=None):
10+ def __init__(self, name, version, architecture, origin=None,
11+ maintainer=None, support=None):
12 """Create the Metadata for a hardware pack.
13
14 See the instance variables for a description of the arguments.
15@@ -37,11 +37,13 @@
16 self.origin = origin
17 self.maintainer = maintainer
18 self.support = support
19+ self.architecture = architecture
20
21 def __str__(self):
22 """Get the contents of the metadata file."""
23 metadata = "NAME=%s\n" % self.name
24 metadata += "VERSION=%s\n" % self.version
25+ metadata += "ARCHITECTURE=%s\n" % self.architecture
26 if self.origin is not None:
27 metadata += "ORIGIN=%s\n" % self.origin
28 if self.maintainer is not None:
29
30=== modified file 'hwpack/packages.py'
31--- hwpack/packages.py 2010-09-02 18:58:01 +0000
32+++ hwpack/packages.py 2010-09-02 18:58:01 +0000
33@@ -8,6 +8,13 @@
34
35
36 def get_packages_file(packages):
37+ """Get the Packages file contents indexing `packages`.
38+
39+ :param packages: the packages to index.
40+ :type packages: an iterable of FetchedPackages.
41+ :return: the Packages file contents indexing `packages`.
42+ :rtype: str
43+ """
44 content = ""
45 for package in packages:
46 parts = []
47@@ -15,8 +22,7 @@
48 parts.append(('Version', package.version))
49 parts.append(('Filename', package.filename))
50 parts.append(('Size', str(package.size)))
51- # TODO: architecture support
52- parts.append(('Architecture', 'all'))
53+ parts.append(('Architecture', package.architecture))
54 parts.append(('MD5sum', package.md5))
55 content += "\n".join([": ".join(p) for p in parts])
56 content += "\n\n"
57@@ -24,6 +30,11 @@
58
59
60 class DummyProgress(object):
61+ """An AcquireProgress that silences all output.
62+
63+ This can be used to ensure that apt produces no output
64+ when fetching files.
65+ """
66
67 def start(self):
68 pass
69@@ -63,9 +74,13 @@
70 :ivar md5: the hex representation of the md5sum of the contents of
71 the package.
72 :type md5: str
73+ :ivar architecture: the architecture that the package is for, may be
74+ 'all'.
75+ :type architecture: str
76 """
77
78- def __init__(self, name, version, filename, content, size, md5):
79+ def __init__(self, name, version, filename, content, size, md5,
80+ architecture):
81 """Create a FetchedPackage.
82
83 See the instance variables for the arguments.
84@@ -76,6 +91,7 @@
85 self.content = content
86 self.size = size
87 self.md5 = md5
88+ self.architecture = architecture
89
90 def __eq__(self, other):
91 return (self.name == other.name
92@@ -83,7 +99,8 @@
93 and self.filename == other.filename
94 and self.content.read() == other.content.read()
95 and self.size == other.size
96- and self.md5 == other.md5)
97+ and self.md5 == other.md5
98+ and self.architecture == other.architecture)
99
100 def __hash__(self):
101 return hash(
102@@ -93,7 +110,7 @@
103 class PackageFetcher(object):
104 """A class to fetch packages from a defined list of sources."""
105
106- def __init__(self, sources):
107+ def __init__(self, sources, architecture=None):
108 """Create a PackageFetcher.
109
110 Once created a PackageFetcher should have its `prepare` method
111@@ -102,8 +119,11 @@
112 :param sources: a list of sources such that they can be prefixed
113 with "deb " and fed to apt.
114 :type sources: an iterable of str
115+ :param architecture: the architecture to fetch packages for.
116+ :type architecture: str
117 """
118 self.sources = sources
119+ self.architecture = architecture
120 self.tempdir = None
121
122 def prepare(self):
123@@ -131,6 +151,10 @@
124 with open(sources_list, 'w') as f:
125 for source in self.sources:
126 f.write("deb %s\n" % source)
127+ if self.architecture is not None:
128+ apt_conf = os.path.join(self.tempdir, "etc", "apt", "apt.conf")
129+ with open(apt_conf, 'w') as f:
130+ f.write('Apt {\nArchitecture "%s";\n}\n' % self.architecture)
131 self.cache = Cache(rootdir=self.tempdir, memonly=True)
132 self.cache.update()
133 self.cache.open()
134@@ -149,10 +173,9 @@
135
136 :param packages: a list of package names to install
137 :type packages: an iterable of str
138- :return: a dict containing the filenames of the .debs that were
139- fetched as the keys, and file objects with the contents of
140- those debs as the values.
141- :rtype: a dict mapping str to file-like objects.
142+ :return: a list of the packages that were fetched, with relevant
143+ metdata and the contents of the files available.
144+ :rtype: an iterable of FetchedPackages.
145 :raises KeyError: if any of the package names in the list couldn't
146 be found.
147 """
148@@ -172,6 +195,7 @@
149 (acqfile.destfile, acqfile.error_text))
150 result_package = FetchedPackage(
151 candidate.package.name, candidate.version, base,
152- open(destfile), candidate.size, candidate.md5)
153+ open(destfile), candidate.size, candidate.md5,
154+ candidate.architecture)
155 results.append(result_package)
156 return results
157
158=== modified file 'hwpack/testing.py'
159--- hwpack/testing.py 2010-09-02 18:58:01 +0000
160+++ hwpack/testing.py 2010-09-02 18:58:01 +0000
161@@ -47,10 +47,15 @@
162
163
164 class DummyFetchedPackage(FetchedPackage):
165-
166- def __init__(self, name, version):
167+ """A FetchedPackage with dummy information.
168+
169+ See FetchedPackage for the instance variables.
170+ """
171+
172+ def __init__(self, name, version, architecture="all"):
173 self.name = name
174 self.version = version
175+ self.architecture = architecture
176
177 @property
178 def filename(self):
179@@ -71,9 +76,24 @@
180 return md5sum.hexdigest()
181
182
183-class AptSource(object):
184+class AptSourceFixture(object):
185+ """A fixture that provides an apt source, with packages and indices.
186+
187+ An apt source provides a set of package files, and a Packages file
188+ that allows apt to determine the contents of the source.
189+
190+ :ivar sources_entry: the URI and suite to give to apt to view the
191+ source (i.e. a sources.list line without the "deb" prefix
192+ :type sources_entry: str
193+ """
194
195 def __init__(self, packages):
196+ """Create an AptSourceFixture.
197+
198+ :param packages: a list of packages to add to the source
199+ and index.
200+ :type packages: an iterable of FetchedPackages
201+ """
202 self.packages = packages
203
204 def setUp(self):
205@@ -95,8 +115,24 @@
206
207
208 class TestCaseWithFixtures(TestCase):
209+ """A TestCase with the ability to easily add 'fixtures'.
210+
211+ A fixture is an object which can be created and cleaned up, and
212+ this test case knows how to manage them to ensure that they will
213+ always be cleaned up at the end of the test.
214+ """
215
216 def useFixture(self, fixture):
217+ """Make use of a fixture, ensuring that it will be cleaned up.
218+
219+ Given a fixture, this method will run the `setUp` method of
220+ the fixture, and ensure that its `tearDown` method will be
221+ called at the end of the test, regardless of success or failure.
222+
223+ :param fixture: the fixture to use.
224+ :type fixture: an object with setUp and tearDown methods.
225+ :return: the fixture that was passed in.
226+ """
227 self.addCleanup(fixture.tearDown)
228 fixture.setUp()
229 return fixture
230
231=== modified file 'hwpack/tests/test_hardwarepack.py'
232--- hwpack/tests/test_hardwarepack.py 2010-09-02 18:58:01 +0000
233+++ hwpack/tests/test_hardwarepack.py 2010-09-02 18:58:01 +0000
234@@ -12,56 +12,67 @@
235 class MetadataTests(TestCase):
236
237 def test_name(self):
238- metadata = Metadata("ahwpack", "3")
239+ metadata = Metadata("ahwpack", "3", "armel")
240 self.assertEqual("ahwpack", metadata.name)
241
242 def test_version(self):
243- metadata = Metadata("ahwpack", "3")
244+ metadata = Metadata("ahwpack", "3", "armel")
245 self.assertEqual("3", metadata.version)
246
247+ def test_architecture(self):
248+ metadata = Metadata("ahwpack", "3", "armel")
249+ self.assertEqual("armel", metadata.architecture)
250+
251 def test_default_origin_is_None(self):
252- metadata = Metadata("ahwpack", "4")
253+ metadata = Metadata("ahwpack", "4", "armel")
254 self.assertEqual(None, metadata.origin)
255
256 def test_origin(self):
257- metadata = Metadata("ahwpack", "4", origin="linaro")
258+ metadata = Metadata("ahwpack", "4", "armel", origin="linaro")
259 self.assertEqual("linaro", metadata.origin)
260
261 def test_default_maintainer_is_None(self):
262- metadata = Metadata("ahwpack", "4")
263+ metadata = Metadata("ahwpack", "4", "armel")
264 self.assertEqual(None, metadata.maintainer)
265
266 def test_maintainer(self):
267- metadata = Metadata("ahwpack", "4", maintainer="Some maintainer")
268+ metadata = Metadata(
269+ "ahwpack", "4", "armel", maintainer="Some maintainer")
270 self.assertEqual("Some maintainer", metadata.maintainer)
271
272 def test_default_support_is_None(self):
273- metadata = Metadata("ahwpack", "4")
274+ metadata = Metadata("ahwpack", "4", "armel")
275 self.assertEqual(None, metadata.support)
276
277 def test_support(self):
278- metadata = Metadata("ahwpack", "4", support="supported")
279+ metadata = Metadata("ahwpack", "4", "armel", support="supported")
280 self.assertEqual("supported", metadata.support)
281
282 def test_str(self):
283- metadata = Metadata("ahwpack", "4")
284- self.assertEqual("NAME=ahwpack\nVERSION=4\n", str(metadata))
285+ metadata = Metadata("ahwpack", "4", "armel")
286+ self.assertEqual(
287+ "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n", str(metadata))
288
289 def test_str_with_origin(self):
290- metadata = Metadata("ahwpack", "4", origin="linaro")
291+ metadata = Metadata("ahwpack", "4", "armel", origin="linaro")
292 self.assertEqual(
293- "NAME=ahwpack\nVERSION=4\nORIGIN=linaro\n", str(metadata))
294+ "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\nORIGIN=linaro\n",
295+ str(metadata))
296
297 def test_str_with_maintainer(self):
298- metadata = Metadata("ahwpack", "4", maintainer="Some Maintainer")
299+ metadata = Metadata(
300+ "ahwpack", "4", "armel", maintainer="Some Maintainer")
301 self.assertEqual(
302- "NAME=ahwpack\nVERSION=4\nMAINTAINER=Some Maintainer\n",
303+ "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
304+ "MAINTAINER=Some Maintainer\n",
305 str(metadata))
306
307 def test_str_with_support(self):
308- metadata = Metadata("ahwpack", "4", support="unsupported")
309+ metadata = Metadata("ahwpack", "4", "armel", support="unsupported")
310 self.assertEqual(
311- "NAME=ahwpack\nVERSION=4\nSUPPORT=unsupported\n", str(metadata))
312+ "NAME=ahwpack\nVERSION=4\nARCHITECTURE=armel\n"
313+ "SUPPORT=unsupported\n",
314+ str(metadata))
315
316
317 class HardwarePackHasFile(TarfileHasFile):
318@@ -111,7 +122,7 @@
319
320 def setUp(self):
321 super(HardwarePackTests, self).setUp()
322- self.metadata = Metadata("ahwpack", 4)
323+ self.metadata = Metadata("ahwpack", 4, "armel")
324
325 def test_format_is_1_0(self):
326 hwpack = HardwarePack(self.metadata)
327@@ -122,7 +133,7 @@
328 self.assertEqual("hwpack_ahwpack_4.tar.gz", hwpack.filename())
329
330 def test_filename_with_support(self):
331- metadata = Metadata("ahwpack", "4", support="supported")
332+ metadata = Metadata("ahwpack", "4", "armel", support="supported")
333 hwpack = HardwarePack(metadata)
334 self.assertEqual(
335 "hwpack_ahwpack_4_supported.tar.gz", hwpack.filename())
336@@ -144,7 +155,7 @@
337
338 def test_creates_metadata_file(self):
339 metadata = Metadata(
340- "ahwpack", "4", origin="linaro",
341+ "ahwpack", "4", "armel", origin="linaro",
342 maintainer="Some Maintainer", support="unsupported")
343 hwpack = HardwarePack(metadata)
344 tf = self.get_tarfile(hwpack)
345
346=== modified file 'hwpack/tests/test_packages.py'
347--- hwpack/tests/test_packages.py 2010-09-02 18:58:01 +0000
348+++ hwpack/tests/test_packages.py 2010-09-02 18:58:01 +0000
349@@ -9,7 +9,7 @@
350 PackageFetcher,
351 )
352 from hwpack.testing import (
353- AptSource,
354+ AptSourceFixture,
355 DummyFetchedPackage,
356 TestCaseWithFixtures,
357 )
358@@ -18,12 +18,12 @@
359 class GetPackagesFileTests(TestCase):
360
361 def test_single_stanza(self):
362- package = DummyFetchedPackage("foo", "1.1")
363+ package = DummyFetchedPackage("foo", "1.1", architecture="armel")
364 self.assertEqual("""Package: foo
365 Version: 1.1
366 Filename: %(filename)s
367 Size: %(size)d
368-Architecture: all
369+Architecture: armel
370 MD5sum: %(md5)s
371
372 """ % {
373@@ -44,68 +44,77 @@
374
375 def test_attributes(self):
376 package = FetchedPackage(
377- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
378+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa",
379+ "armel")
380 self.assertEqual("foo", package.name)
381 self.assertEqual("1.1", package.version)
382 self.assertEqual("foo_1.1.deb", package.filename)
383 self.assertEqual("xxxx", package.content.read())
384 self.assertEqual(4, package.size)
385 self.assertEqual("aaaa", package.md5)
386+ self.assertEqual("armel", package.architecture)
387
388 def test_equal(self):
389 package1 = FetchedPackage(
390- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
391+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
392 package2 = FetchedPackage(
393- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
394+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
395 self.assertEqual(package1, package2)
396
397 def test_not_equal_different_name(self):
398 package1 = FetchedPackage(
399- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
400+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
401 package2 = FetchedPackage(
402- "bar", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
403+ "bar", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
404 self.assertNotEqual(package1, package2)
405
406 def test_not_equal_different_version(self):
407 package1 = FetchedPackage(
408- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
409+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
410 package2 = FetchedPackage(
411- "foo", "1.2", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
412+ "foo", "1.2", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
413 self.assertNotEqual(package1, package2)
414
415 def test_not_equal_different_filename(self):
416 package1 = FetchedPackage(
417- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
418+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
419 package2 = FetchedPackage(
420- "foo", "1.1", "afoo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
421+ "foo", "1.1", "afoo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
422 self.assertNotEqual(package1, package2)
423
424 def test_not_equal_different_content(self):
425 package1 = FetchedPackage(
426- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
427+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
428 package2 = FetchedPackage(
429- "foo", "1.1", "foo_1.1.deb", StringIO("yyyy"), 4, "aaaa")
430+ "foo", "1.1", "foo_1.1.deb", StringIO("yyyy"), 4, "aaaa", "armel")
431 self.assertNotEqual(package1, package2)
432
433 def test_not_equal_different_size(self):
434 package1 = FetchedPackage(
435- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
436+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
437 package2 = FetchedPackage(
438- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 5, "aaaa")
439+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 5, "aaaa", "armel")
440 self.assertNotEqual(package1, package2)
441
442 def test_not_equal_different_md5(self):
443 package1 = FetchedPackage(
444- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
445- package2 = FetchedPackage(
446- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "bbbb")
447+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
448+ package2 = FetchedPackage(
449+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "bbbb", "armel")
450+ self.assertNotEqual(package1, package2)
451+
452+ def test_not_equal_different_architecture(self):
453+ package1 = FetchedPackage(
454+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
455+ package2 = FetchedPackage(
456+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "i386")
457 self.assertNotEqual(package1, package2)
458
459 def test_equal_hash_equal(self):
460 package1 = FetchedPackage(
461- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
462+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
463 package2 = FetchedPackage(
464- "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa")
465+ "foo", "1.1", "foo_1.1.deb", StringIO("xxxx"), 4, "aaaa", "armel")
466 self.assertEqual(hash(package1), hash(package2))
467
468
469@@ -164,8 +173,8 @@
470 fetcher.tempdir, "var", "lib", "apt", "lists", "partial")))
471
472 def test_prepare_creates_etc_apt_sources_list_file(self):
473- source1 = self.useFixture(AptSource([]))
474- source2 = self.useFixture(AptSource([]))
475+ source1 = self.useFixture(AptSourceFixture([]))
476+ source2 = self.useFixture(AptSourceFixture([]))
477 fetcher = PackageFetcher(
478 [source1.sources_entry, source2.sources_entry])
479 self.addCleanup(fetcher.cleanup)
480@@ -176,8 +185,18 @@
481 open(os.path.join(
482 fetcher.tempdir, "etc", "apt", "sources.list")).read())
483
484- def get_fetcher(self, sources):
485- fetcher = PackageFetcher([s.sources_entry for s in sources])
486+ def test_prepare_with_arch_creates_etc_apt_apt_conf(self):
487+ fetcher = PackageFetcher([], architecture="arch")
488+ self.addCleanup(fetcher.cleanup)
489+ fetcher.prepare()
490+ self.assertEqual(
491+ 'Apt {\nArchitecture "arch";\n}\n',
492+ open(os.path.join(
493+ fetcher.tempdir, "etc", "apt", "apt.conf")).read())
494+
495+ def get_fetcher(self, sources, architecture=None):
496+ fetcher = PackageFetcher(
497+ [s.sources_entry for s in sources], architecture=architecture)
498 self.addCleanup(fetcher.cleanup)
499 fetcher.prepare()
500 return fetcher
501@@ -188,32 +207,32 @@
502
503 def test_fetch_packages_not_found_because_not_in_sources(self):
504 available_package = DummyFetchedPackage("foo", "1.0")
505- source = self.useFixture(AptSource([available_package]))
506+ source = self.useFixture(AptSourceFixture([available_package]))
507 fetcher = self.get_fetcher([source])
508 self.assertRaises(KeyError, fetcher.fetch_packages, ["nothere"])
509
510 def test_fetch_packages_not_found_one_of_two_missing(self):
511 available_package = DummyFetchedPackage("foo", "1.0")
512- source = self.useFixture(AptSource([available_package]))
513+ source = self.useFixture(AptSourceFixture([available_package]))
514 fetcher = self.get_fetcher([source])
515 self.assertRaises(
516 KeyError, fetcher.fetch_packages, ["foo", "nothere"])
517
518 def test_fetch_packges_fetches_no_packages(self):
519 available_package = DummyFetchedPackage("foo", "1.0")
520- source = self.useFixture(AptSource([available_package]))
521+ source = self.useFixture(AptSourceFixture([available_package]))
522 fetcher = self.get_fetcher([source])
523 self.assertEqual(0, len(fetcher.fetch_packages([])))
524
525 def test_fetch_packges_fetches_single_package(self):
526 available_package = DummyFetchedPackage("foo", "1.0")
527- source = self.useFixture(AptSource([available_package]))
528+ source = self.useFixture(AptSourceFixture([available_package]))
529 fetcher = self.get_fetcher([source])
530 self.assertEqual(1, len(fetcher.fetch_packages(["foo"])))
531
532- def test_fetch_packges_fetches_correct_packge(self):
533+ def test_fetch_packges_fetches_correct_package(self):
534 available_package = DummyFetchedPackage("foo", "1.0")
535- source = self.useFixture(AptSource([available_package]))
536+ source = self.useFixture(AptSourceFixture([available_package]))
537 fetcher = self.get_fetcher([source])
538 self.assertEqual(
539 available_package, fetcher.fetch_packages(["foo"])[0])
540@@ -223,7 +242,7 @@
541 DummyFetchedPackage("bar", "1.0"),
542 DummyFetchedPackage("foo", "1.0"),
543 ]
544- source = self.useFixture(AptSource(available_packages))
545+ source = self.useFixture(AptSourceFixture(available_packages))
546 fetcher = self.get_fetcher([source])
547 self.assertEqual(2, len(fetcher.fetch_packages(["foo", "bar"])))
548
549@@ -232,7 +251,7 @@
550 DummyFetchedPackage("foo", "1.0"),
551 DummyFetchedPackage("bar", "1.0"),
552 ]
553- source = self.useFixture(AptSource(available_packages))
554+ source = self.useFixture(AptSourceFixture(available_packages))
555 fetcher = self.get_fetcher([source])
556 fetched = fetcher.fetch_packages(["foo", "bar"])
557 self.assertEqual(available_packages[0], fetched[0])
558@@ -243,7 +262,7 @@
559 DummyFetchedPackage("bar", "1.0"),
560 DummyFetchedPackage("bar", "1.1"),
561 ]
562- source = self.useFixture(AptSource(available_packages))
563+ source = self.useFixture(AptSourceFixture(available_packages))
564 fetcher = self.get_fetcher([source])
565 fetched = fetcher.fetch_packages(["bar"])
566 self.assertEqual(available_packages[1], fetched[0])
567@@ -251,8 +270,27 @@
568 def test_fetch_packages_fetches_newest_from_multiple_sources(self):
569 old_source_packages = [DummyFetchedPackage("bar", "1.0")]
570 new_source_packages = [DummyFetchedPackage("bar", "1.1")]
571- old_source = self.useFixture(AptSource(old_source_packages))
572- new_source = self.useFixture(AptSource(new_source_packages))
573+ old_source = self.useFixture(AptSourceFixture(old_source_packages))
574+ new_source = self.useFixture(AptSourceFixture(new_source_packages))
575 fetcher = self.get_fetcher([old_source, new_source])
576 fetched = fetcher.fetch_packages(["bar"])
577 self.assertEqual(new_source_packages[0], fetched[0])
578+
579+ def test_fetch_package_records_correct_architecture(self):
580+ available_package = DummyFetchedPackage(
581+ "foo", "1.0", architecture="nonexistant")
582+ source = self.useFixture(AptSourceFixture([available_package]))
583+ fetcher = self.get_fetcher([source], architecture="nonexistant")
584+ self.assertEqual(
585+ "nonexistant", fetcher.fetch_packages(["foo"])[0].architecture)
586+
587+ def test_fetch_package_fetches_from_correct_architecture(self):
588+ wanted_package = DummyFetchedPackage(
589+ "foo", "1.0", architecture="arch1")
590+ unwanted_package = DummyFetchedPackage(
591+ "foo", "1.1", architecture="arch2")
592+ source = self.useFixture(
593+ AptSourceFixture([wanted_package, unwanted_package]))
594+ fetcher = self.get_fetcher([source], architecture="arch1")
595+ self.assertEqual(
596+ wanted_package, fetcher.fetch_packages(["foo"])[0])

Subscribers

People subscribed via source and target branches