diff options
Diffstat (limited to 'tests/test_distro.py')
-rw-r--r-- | tests/test_distro.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/test_distro.py b/tests/test_distro.py index e22da68..88fa984 100644 --- a/tests/test_distro.py +++ b/tests/test_distro.py @@ -16,9 +16,15 @@ import unittest -from whatmaps.distro import Distro +from mock import patch -from . import context +try: + import lsb_release + have_lsb_release=True +except ImportError: + have_lsb_release=False + +from whatmaps.distro import Distro, detect class Pkg(object): name = 'doesnotmatter' @@ -38,3 +44,13 @@ class TestDistro(unittest.TestCase): self.assertEqual(Distro.pkg_services(Pkg), []) self.assertEqual(Distro.pkg_service_blacklist(Pkg), []) self.assertFalse(Distro.has_apt()) + + + @unittest.skipUnless(have_lsb_release, "lsb_release not installed") + def test_detect_via_lsb_release_module(self): + "Detect distro via lsb_release" + with patch('lsb_release.get_distro_information', return_value={'ID': 'Debian'}): + # Make sure we don't use the fallback + with patch('os.path.exists', return_value=False): + d = detect() + self.assertEqual(d.id, 'Debian') |