summaryrefslogtreecommitdiffstats
path: root/tests/test_debfile_multiarch.py
blob: 24f02653448acb86a905a937802ac3626874f96b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/python3
#
# Copyright (C) 2010 Michael Vogt <mvo@ubuntu.com>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
"""Unit tests for verifying the correctness of DebPackage in apt.debfile."""
import sys
import unittest

from test_all import get_library_dir

libdir = get_library_dir()
if libdir:
    sys.path.insert(0, libdir)
import apt_pkg
import testcommon

import apt
import apt.debfile


class TestDebfileMultiarch(testcommon.TestCase):
    """test the multiarch debfile"""

    def test_multiarch_deb_check(self):
        if apt_pkg.get_architectures() != ["amd64", "i386"]:
            # TODO: use unittest.skip
            # logging.warning("skipping test because running on a "
            #                "non-multiarch system")
            return
        deb = apt.debfile.DebPackage("./data/test_debs/multiarch-test1_i386.deb")
        deb.check()
        missing = deb.missing_deps
        # print missing
        self.assertFalse("dpkg:i386" in missing)

    @unittest.skip("BROKEN, lib3ds-1-3 is m-a now")
    def test_multiarch_conflicts(self):
        cache = apt.Cache()
        # WARNING: this assumes that lib3ds-1-3 is a non-multiarch lib
        # use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work
        canary = "lib3ds-1-3"
        if canary not in cache:
            # TODO: use unittest.skip
            # logging.warning("skipping test because %s is missing" % canary)
            return
        cache[canary].mark_install()
        deb = apt.debfile.DebPackage(
            "./data/test_debs/multiarch-test1_i386.deb", cache=cache
        )
        # this deb should now not be installable
        installable = deb.check()
        # print deb._failure_string
        self.assertFalse(installable)
        self.assertEqual(
            deb._failure_string, "Conflicts with the installed package 'lib3ds-1-3'"
        )


if __name__ == "__main__":
    unittest.main()