def test_adds_multiple_sources_list_files(self): hwpack = HardwarePack(self.metadata) source1 = 'http://example.org/ ubuntu main universe' source2 = 'http://example.org/ linaro' hwpack.add_apt_sources({'ubuntu': source1, 'linaro': source2}) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("sources.list.d/ubuntu.list", content="deb " + source1 + "\n")) self.assertThat( tf, HardwarePackHasFile("sources.list.d/linaro.list", content="deb " + source2 + "\n"))
def test_adds_multiple_packages_at_once(self): package1 = DummyFetchedPackage("foo", "1.1") package2 = DummyFetchedPackage("bar", "1.1") hwpack = HardwarePack(self.metadata) hwpack.add_packages([package1, package2]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("pkgs/%s" % package1.filename, content=package1.content.read())) self.assertThat( tf, HardwarePackHasFile("pkgs/%s" % package2.filename, content=package2.content.read()))
def test_Packages_file_empty_with_no_deb_content(self): package1 = DummyFetchedPackage("foo", "1.1", no_content=True) package2 = DummyFetchedPackage("bar", "1.1", no_content=True) hwpack = HardwarePack(self.metadata) hwpack.add_packages([package1, package2]) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("pkgs/Packages", content=""))
def test_add_packages_without_content_leaves_out_debs(self): package1 = DummyFetchedPackage("foo", "1.1", no_content=True) hwpack = HardwarePack(self.metadata) hwpack.add_packages([package1]) tf = self.get_tarfile(hwpack) self.assertThat( tf, Not(HardwarePackHasFile("pkgs/%s" % package1.filename)))
def test_creates_FORMAT_file(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("FORMAT", content=hwpack.format.__str__() + "\n"))
def test_manifest_contains_package_info(self): package1 = DummyFetchedPackage("foo", "1.1") package2 = DummyFetchedPackage("bar", "1.2") hwpack = HardwarePack(self.metadata) hwpack.add_packages([package1, package2]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("manifest", content="foo=1.1\nbar=1.2\n"))
def test_adds_sources_list_file(self): hwpack = HardwarePack(self.metadata) source = 'http://example.org/ ubuntu' hwpack.add_apt_sources({'ubuntu': source}) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("sources.list.d/ubuntu.list", content="deb " + source + "\n"))
def test_adds_packages(self): package = DummyFetchedPackage("foo", "1.1") hwpack = HardwarePack(self.metadata) hwpack.add_packages([package]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("pkgs/%s" % package.filename, content=package.content.read()))
def test_creates_metadata_file(self): metadata = Metadata("ahwpack", "4", "armel", origin="linaro", maintainer="Some Maintainer", support="unsupported") hwpack = HardwarePack(metadata) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("metadata", content=str(metadata)))
def test_overwrites_sources_list_file(self): hwpack = HardwarePack(self.metadata) old_source = 'http://example.org/ ubuntu' hwpack.add_apt_sources({'ubuntu': old_source}) new_source = 'http://example.org/ ubuntu main universe' hwpack.add_apt_sources({'ubuntu': new_source}) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("sources.list.d/ubuntu.list", content="deb " + new_source + "\n"))
def test_Packages_file_correct_contents_with_packages(self): package1 = DummyFetchedPackage("foo", "1.1") package2 = DummyFetchedPackage("bar", "1.1") hwpack = HardwarePack(self.metadata) hwpack.add_packages([package1, package2]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("pkgs/Packages", content=get_packages_file([package1, package2])))
def test_add_dependency_package_adds_package(self): hwpack = HardwarePack(self.metadata) hwpack.add_dependency_package([]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile( "pkgs/%s_%s_%s.deb" % ('hwpack-' + self.metadata.name, self.metadata.version, self.metadata.architecture), content_matcher=MatchesAsPackageContent( MatchesStructure( name=Equals('hwpack-' + self.metadata.name), architecture=Equals(self.metadata.architecture), depends=Equals(None), version=Equals(self.metadata.version)))))
def test_password_removed_from_urls(self): hwpack = HardwarePack(self.metadata) url = "https://*****:*****@hostname/url precise main" hwpack.add_apt_sources({"protected": url}) tf = self.get_tarfile(hwpack) try: self.assertThat( tf, HardwarePackHasFile("sources.list.d/protected.list", content="deb " + url + "\n")) except MismatchError: pass # Expect to not find the password protected URL else: self.assertTrue(False, "Found password protected URL in hwpack")
def test_add_dependency_package_adds_package_to_Packages(self): hwpack = HardwarePack(self.metadata) hwpack.add_dependency_package(["foo", "bar (= 1.0)"]) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile( "pkgs/Packages", content_matcher=MatchesAsPackagesFile( MatchesStructure( name=Equals('hwpack-' + self.metadata.name), architecture=Equals(self.metadata.architecture), depends=MatchesPackageRelationshipList( [Equals("foo"), Equals("bar (= 1.0)")]), version=Equals(self.metadata.version)))))
def test_creates_sources_list_gpg_dir(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat( tf, HardwarePackHasFile("sources.list.d.gpg", type=tarfile.DIRTYPE))
def test_creates_manifest_file(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("manifest"))
def test_creates_pkgs_dir(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("pkgs", type=tarfile.DIRTYPE))
def test_creates_Packages_file(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("pkgs/Packages"))
def test_Packages_file_empty_with_no_packages(self): hwpack = HardwarePack(self.metadata) tf = self.get_tarfile(hwpack) self.assertThat(tf, HardwarePackHasFile("pkgs/Packages", content=""))