예제 #1
0
 def test_inserts_generic_link_for_generic_kflavor(self):
     product_mapping = ProductMapping()
     product = self.make_product(subarch='ga-16.04', kflavor='generic')
     product_mapping.add(product, 'ga-16.04')
     repo_writer = download_resources.RepoWriter(None, None,
                                                 product_mapping)
     self.patch(download_resources,
                'products_exdata').return_value = product
     # Prevent MAAS from trying to actually write the file.
     mock_insert_file = self.patch(download_resources, 'insert_file')
     mock_link_resources = self.patch(download_resources, 'link_resources')
     # We only need to provide the product as the other fields are only used
     # when writing the actual files to disk.
     repo_writer.insert_item(product, None, None, None, None)
     # None is used for the store and the content source as we're not
     # writing anything to disk.
     self.assertThat(
         mock_insert_file,
         MockCalledOnceWith(None, os.path.basename(product['path']),
                            product['sha256'],
                            {'sha256': product['sha256']}, product['size'],
                            None))
     # links are mocked out by the mock_insert_file above.
     self.assertThat(
         mock_link_resources,
         MockCalledOnceWith(snapshot_path=None,
                            links=mock.ANY,
                            osystem=product['os'],
                            arch=product['arch'],
                            release=product['release'],
                            label=product['label'],
                            subarches={'ga-16.04', 'generic'},
                            bootloader_type=None))
예제 #2
0
 def test_only_creates_links_for_its_own_subarch(self):
     # Regression test for LP:1656425
     product_name = factory.make_name("product_name")
     version_name = factory.make_name("version_name")
     product_mapping = ProductMapping()
     for subarch in [
             "hwe-p",
             "hwe-q",
             "hwe-r",
             "hwe-s",
             "hwe-t",
             "hwe-u",
             "hwe-v",
             "hwe-w",
             "ga-16.04",
     ]:
         product = self.make_product(
             product_name=product_name,
             version_name=version_name,
             subarch=subarch,
         )
         product_mapping.add(product, subarch)
     repo_writer = download_resources.RepoWriter(None, None,
                                                 product_mapping)
     self.patch(download_resources,
                "products_exdata").return_value = product
     # Prevent MAAS from trying to actually write the file.
     mock_insert_file = self.patch(download_resources, "insert_file")
     mock_link_resources = self.patch(download_resources, "link_resources")
     # We only need to provide the product as the other fields are only used
     # when writing the actual files to disk.
     repo_writer.insert_item(product, None, None, None, None)
     # None is used for the store and the content source as we're not
     # writing anything to disk.
     self.assertThat(
         mock_insert_file,
         MockCalledOnceWith(
             None,
             os.path.basename(product["path"]),
             product["sha256"],
             {"sha256": product["sha256"]},
             product["size"],
             None,
         ),
     )
     # links are mocked out by the mock_insert_file above.
     self.assertThat(
         mock_link_resources,
         MockCalledOnceWith(
             snapshot_path=None,
             links=mock.ANY,
             osystem=product["os"],
             arch=product["arch"],
             release=product["release"],
             label=product["label"],
             subarches={"ga-16.04"},
             bootloader_type=None,
         ),
     )
예제 #3
0
 def test_inserts_generic_link_for_generic_kflavor_old_hwe_style_ga(self):
     # Regression test for LP:1768323
     product_mapping = ProductMapping()
     product = self.make_product(
         subarch="hwe-p", kflavor="generic", release="precise"
     )
     product_mapping.add(product, "hwe-p")
     repo_writer = download_resources.RepoWriter(
         None, None, product_mapping
     )
     self.patch(
         download_resources, "products_exdata"
     ).return_value = product
     # Prevent MAAS from trying to actually write the file.
     mock_insert_file = self.patch(download_resources, "insert_file")
     mock_link_resources = self.patch(download_resources, "link_resources")
     # We only need to provide the product as the other fields are only used
     # when writing the actual files to disk.
     repo_writer.insert_item(product, None, None, None, None)
     # None is used for the store and the content source as we're not
     # writing anything to disk.
     self.assertThat(
         mock_insert_file,
         MockCalledOnceWith(
             None,
             os.path.basename(product["path"]),
             product["sha256"],
             {"sha256": product["sha256"]},
             product["size"],
             None,
         ),
     )
     # links are mocked out by the mock_insert_file above.
     self.assertThat(
         mock_link_resources,
         MockCalledOnceWith(
             snapshot_path=None,
             links=mock.ANY,
             osystem=product["os"],
             arch=product["arch"],
             release=product["release"],
             label=product["label"],
             subarches={"hwe-p", "generic"},
             bootloader_type=None,
         ),
     )
예제 #4
0
 def test_inserts_archive(self):
     product_mapping = ProductMapping()
     subarch = factory.make_name("subarch")
     product = self.make_product(ftype="archive.tar.xz", subarch=subarch)
     product_mapping.add(product, subarch)
     repo_writer = download_resources.RepoWriter(
         None, None, product_mapping
     )
     self.patch(
         download_resources, "products_exdata"
     ).return_value = product
     # Prevent MAAS from trying to actually write the file.
     mock_extract_archive_tar = self.patch(
         download_resources, "extract_archive_tar"
     )
     mock_link_resources = self.patch(download_resources, "link_resources")
     # We only need to provide the product as the other fields are only used
     # when writing the actual files to disk.
     repo_writer.insert_item(product, None, None, None, None)
     # None is used for the store and the content source as we're not
     # writing anything to disk.
     self.assertThat(
         mock_extract_archive_tar,
         MockCalledOnceWith(
             None,
             os.path.basename(product["path"]),
             product["sha256"],
             {"sha256": product["sha256"]},
             product["size"],
             None,
         ),
     )
     # links are mocked out by the mock_insert_file above.
     self.assertThat(
         mock_link_resources,
         MockCalledOnceWith(
             snapshot_path=None,
             links=mock.ANY,
             osystem=product["os"],
             arch=product["arch"],
             release=product["release"],
             label=product["label"],
             subarches={subarch},
             bootloader_type=None,
         ),
     )
예제 #5
0
 def test_only_creates_links_for_its_own_subarch(self):
     # Regression test for LP:1656425
     product_name = factory.make_name('product_name')
     version_name = factory.make_name('version_name')
     product_mapping = ProductMapping()
     for subarch in [
             'hwe-p', 'hwe-q', 'hwe-r', 'hwe-s', 'hwe-t', 'hwe-u', 'hwe-v',
             'hwe-w', 'ga-16.04'
     ]:
         product = self.make_product(product_name=product_name,
                                     version_name=version_name,
                                     subarch=subarch)
         product_mapping.add(product, subarch)
     repo_writer = download_resources.RepoWriter(None, None,
                                                 product_mapping)
     self.patch(download_resources,
                'products_exdata').return_value = product
     # Prevent MAAS from trying to actually write the file.
     mock_insert_file = self.patch(download_resources, 'insert_file')
     mock_link_resources = self.patch(download_resources, 'link_resources')
     # We only need to provide the product as the other fields are only used
     # when writing the actual files to disk.
     repo_writer.insert_item(product, None, None, None, None)
     # None is used for the store and the content source as we're not
     # writing anything to disk.
     self.assertThat(
         mock_insert_file,
         MockCalledOnceWith(None, os.path.basename(product['path']),
                            product['sha256'],
                            {'sha256': product['sha256']}, product['size'],
                            None))
     # links are mocked out by the mock_insert_file above.
     self.assertThat(
         mock_link_resources,
         MockCalledOnceWith(snapshot_path=None,
                            links=mock.ANY,
                            osystem=product['os'],
                            arch=product['arch'],
                            release=product['release'],
                            label=product['label'],
                            subarches={'ga-16.04'},
                            bootloader_type=None))