199
202
def test_inserts_archive(self):
200
203
product = self.make_product('archive.tar.xz')
202
repo_writer = download_resources.RepoWriter(None, None, None)
204
product_mapping = ProductMapping()
205
subarch = factory.make_name('subarch')
206
product_mapping.add(product, subarch)
207
repo_writer = download_resources.RepoWriter(
208
None, None, product_mapping)
204
210
download_resources, 'products_exdata').return_value = product
205
self.patch(repo_writer, 'product_mapping')
206
211
mock_extract_archive_tar = self.patch(
207
212
download_resources, 'extract_archive_tar')
208
213
mock_link_resources = self.patch(download_resources, 'link_resources')
217
222
MockCalledOnceWith(
218
223
snapshot_path=None, links=mock.ANY, osystem=product['os'],
219
224
arch=product['arch'], release=product['release'],
220
label=product['label'], subarches=mock.ANY,
225
label=product['label'], subarches=[subarch],
221
226
bootloader_type=None))
223
228
def test_inserts_root_image(self):
224
229
product = self.make_product('root-image.gz')
226
repo_writer = download_resources.RepoWriter(None, None, None)
230
product_mapping = ProductMapping()
231
subarch = factory.make_name('subarch')
232
product_mapping.add(product, subarch)
233
repo_writer = download_resources.RepoWriter(
234
None, None, product_mapping)
228
236
download_resources, 'products_exdata').return_value = product
229
self.patch(repo_writer, 'product_mapping')
230
237
mock_insert_root_image = self.patch(
231
238
download_resources, 'insert_root_image')
232
239
mock_link_resources = self.patch(download_resources, 'link_resources')
241
248
MockCalledOnceWith(
242
249
snapshot_path=None, links=mock.ANY, osystem=product['os'],
243
250
arch=product['arch'], release=product['release'],
244
label=product['label'], subarches=mock.ANY,
251
label=product['label'], subarches=[subarch],
245
252
bootloader_type=None))
247
254
def test_inserts_file(self):
248
255
product = self.make_product()
250
repo_writer = download_resources.RepoWriter(None, None, None)
252
download_resources, 'products_exdata').return_value = product
253
self.patch(repo_writer, 'product_mapping')
254
mock_insert_file = self.patch(download_resources, 'insert_file')
255
mock_link_resources = self.patch(download_resources, 'link_resources')
256
repo_writer.insert_item(product, None, None, None, None)
260
mock.ANY, os.path.basename(product['path']), product['sha256'],
261
{'sha256': product['sha256']}, product['size'], None))
265
snapshot_path=None, links=mock.ANY, osystem=product['os'],
266
arch=product['arch'], release=product['release'],
267
label=product['label'], subarches=mock.ANY,
256
product_mapping = ProductMapping()
257
subarch = factory.make_name('subarch')
258
product_mapping.add(product, subarch)
259
repo_writer = download_resources.RepoWriter(
260
None, None, product_mapping)
262
download_resources, 'products_exdata').return_value = product
263
mock_insert_file = self.patch(download_resources, 'insert_file')
264
mock_link_resources = self.patch(download_resources, 'link_resources')
265
repo_writer.insert_item(product, None, None, None, None)
269
mock.ANY, os.path.basename(product['path']), product['sha256'],
270
{'sha256': product['sha256']}, product['size'], None))
274
snapshot_path=None, links=mock.ANY, osystem=product['os'],
275
arch=product['arch'], release=product['release'],
276
label=product['label'], subarches=[subarch],
277
bootloader_type=None))
279
def test_inserts_rolling_links(self):
280
product = self.make_product()
281
product['subarch'] = 'hwe-16.04'
282
product['rolling'] = True
283
product_mapping = ProductMapping()
284
product_mapping.add(product, 'hwe-16.04')
285
repo_writer = download_resources.RepoWriter(
286
None, None, product_mapping)
288
download_resources, 'products_exdata').return_value = product
289
mock_insert_file = self.patch(download_resources, 'insert_file')
290
mock_link_resources = self.patch(download_resources, 'link_resources')
291
repo_writer.insert_item(product, None, None, None, None)
295
mock.ANY, os.path.basename(product['path']), product['sha256'],
296
{'sha256': product['sha256']}, product['size'], None))
300
snapshot_path=None, links=mock.ANY, osystem=product['os'],
301
arch=product['arch'], release=product['release'],
302
label=product['label'], subarches=['hwe-16.04', 'hwe-rolling'],
268
303
bootloader_type=None))