예제 #1
0
def test_get_filtered_stage_package_empty_ignore_filter(
        mock_get_packages_in_base):
    mock_get_packages_in_base.return_value = [
        DebPackage(name="some-base-pkg"),
        DebPackage(name="some-other-base-pkg"),
    ]

    filtered_names = repo._deb._get_filtered_stage_package_names(
        base="core00", package_list=[])

    assert filtered_names == {"some-base-pkg", "some-other-base-pkg"}
예제 #2
0
 def test_hardcoded_bases(self):
     for base in ("core", "core16", "core18"):
         packages = [
             DebPackage.from_unparsed(p)
             for p in repo._deb._DEFAULT_FILTERED_STAGE_PACKAGES
         ]
         assert repo._deb.get_packages_in_base(base=base) == packages
예제 #3
0
    def test_package_list_from_dpkg_list(self, mock_dpkg_list_path):
        temp_dir = self.useFixture(fixtures.TempDir())
        dpkg_list_path = Path(f"{temp_dir.path}/dpkg.list")
        mock_dpkg_list_path.return_value = dpkg_list_path
        with dpkg_list_path.open("w") as dpkg_list_file:
            print(
                textwrap.dedent("""\
            Desired=Unknown/Install/Remove/Purge/Hold
            | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
            |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
            ||/ Name                          Version                    Architecture Description
            +++-=============================-==========================-============-===========
            ii  adduser                       3.118ubuntu1               all          add and rem
            ii  apparmor                      2.13.3-7ubuntu2            amd64        user-space
            ii  apt                           2.0.1                      amd64        commandline
            ii  base-files                    11ubuntu4                  amd64        Debian base
            ii  base-passwd                   3.5.47                     amd64        Debian base
            ii  zlib1g:amd64                  1:1.2.11.dfsg-2ubuntu1     amd64        compression
            """),
                file=dpkg_list_file,
            )

        self.expectThat(
            repo._deb.get_packages_in_base(base="core20"),
            Equals([
                DebPackage(name="adduser"),
                DebPackage(name="apparmor"),
                DebPackage(name="apt"),
                DebPackage(name="base-files"),
                DebPackage(name="base-passwd"),
                DebPackage(name="zlib1g", arch="amd64"),
            ]),
        )
예제 #4
0
def test_parse_version():
    assert DebPackage.from_unparsed("foo=4.5") == DebPackage(
        name="foo", arch=None, version="4.5"
    )
예제 #5
0
def test_parse_arch_and_version():
    assert DebPackage.from_unparsed("foo:arch=4.5") == DebPackage(
        name="foo", arch="arch", version="4.5"
    )
예제 #6
0
def test_parse_arch():
    assert DebPackage.from_unparsed("foo:arch") == DebPackage(
        name="foo", arch="arch", version=None
    )
예제 #7
0
def test_parse_simple():
    assert DebPackage.from_unparsed("foo") == DebPackage(
        name="foo", arch=None, version=None
    )
예제 #8
0
def test_basic():
    package = DebPackage(name="foo", arch="arch", version="1.0")

    assert package.name == "foo"
    assert package.arch == "arch"
    assert package.version == "1.0"
예제 #9
0
def test_get_filtered_stage_package_restricts_core20_ignore_filter(
    mock_get_packages_in_base, ):
    mock_get_packages_in_base.return_value = [
        DebPackage(name="foo"),
        DebPackage(name="foo2"),
        DebPackage(name="python3-attr"),
        DebPackage(name="python3-blinker"),
        DebPackage(name="python3-certifi"),
        DebPackage(name="python3-cffi-backend"),
        DebPackage(name="python3-chardet"),
        DebPackage(name="python3-configobj"),
        DebPackage(name="python3-cryptography"),
        DebPackage(name="python3-idna"),
        DebPackage(name="python3-importlib-metadata"),
        DebPackage(name="python3-jinja2"),
        DebPackage(name="python3-json-pointer"),
        DebPackage(name="python3-jsonpatch"),
        DebPackage(name="python3-jsonschema"),
        DebPackage(name="python3-jwt"),
        DebPackage(name="python3-lib2to3"),
        DebPackage(name="python3-markupsafe"),
        DebPackage(name="python3-more-itertools"),
        DebPackage(name="python3-netifaces"),
        DebPackage(name="python3-oauthlib"),
        DebPackage(name="python3-pyrsistent"),
        DebPackage(name="python3-pyudev"),
        DebPackage(name="python3-requests"),
        DebPackage(name="python3-requests-unixsocket"),
        DebPackage(name="python3-serial"),
        DebPackage(name="python3-six"),
        DebPackage(name="python3-urllib3"),
        DebPackage(name="python3-urwid"),
        DebPackage(name="python3-yaml"),
        DebPackage(name="python3-zipp"),
    ]

    filtered_names = repo._deb._get_filtered_stage_package_names(
        base="core20", package_list=[])

    assert filtered_names == {"foo", "foo2"}