~elementary-os/elementaryos/os-patch-python-apt-bionic

« back to all changes in this revision

Viewing changes to tests/test_debfile_multiarch.py

  • Committer: RabbitBot
  • Date: 2018-02-05 14:13:49 UTC
  • Revision ID: rabbitbot@elementary.io-20180205141349-gv2qwxlorag06463
Initial import, version 1.4.0~beta3ubuntu1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# Copyright (C) 2010 Michael Vogt <mvo@ubuntu.com>
 
5
#
 
6
# Copying and distribution of this file, with or without modification,
 
7
# are permitted in any medium without royalty provided the copyright
 
8
# notice and this notice are preserved.
 
9
"""Unit tests for verifying the correctness of DebPackage in apt.debfile."""
 
10
import unittest
 
11
 
 
12
from test_all import get_library_dir
 
13
import sys
 
14
libdir = get_library_dir()
 
15
if libdir:
 
16
    sys.path.insert(0, libdir)
 
17
import apt
 
18
import apt_pkg
 
19
import apt.debfile
 
20
 
 
21
import testcommon
 
22
 
 
23
 
 
24
class TestDebfileMultiarch(testcommon.TestCase):
 
25
    """ test the multiarch debfile """
 
26
 
 
27
    def test_multiarch_deb_check(self):
 
28
        if apt_pkg.get_architectures() != ["amd64", "i386"]:
 
29
            # TODO: use unittest.skip
 
30
            #logging.warning("skipping test because running on a "
 
31
            #                "non-multiarch system")
 
32
            return
 
33
        deb = apt.debfile.DebPackage(
 
34
            "./data/test_debs/multiarch-test1_i386.deb")
 
35
        deb.check()
 
36
        missing = deb.missing_deps
 
37
        #print missing
 
38
        self.assertFalse("dpkg:i386" in missing)
 
39
 
 
40
    @unittest.skip("BROKEN, lib3ds-1-3 is m-a now")
 
41
    def test_multiarch_conflicts(self):
 
42
        cache = apt.Cache()
 
43
        # WARNING: this assumes that lib3ds-1-3 is a non-multiarch lib
 
44
        # use "lib3ds-1-3" as a test to see if non-multiach lib conflicts work
 
45
        canary = "lib3ds-1-3"
 
46
        if canary not in cache:
 
47
            # TODO: use unittest.skip
 
48
            #logging.warning("skipping test because %s is missing" % canary)
 
49
            return
 
50
        cache[canary].mark_install()
 
51
        deb = apt.debfile.DebPackage(
 
52
            "./data/test_debs/multiarch-test1_i386.deb", cache=cache)
 
53
        # this deb should now not be installable
 
54
        installable = deb.check()
 
55
        #print deb._failure_string
 
56
        self.assertFalse(installable)
 
57
        self.assertEqual(deb._failure_string,
 
58
                         "Conflicts with the installed package 'lib3ds-1-3'")
 
59
 
 
60
 
 
61
if __name__ == "__main__":
 
62
    unittest.main()