diff options
Diffstat (limited to 'cloudinit/tests')
| -rw-r--r-- | cloudinit/tests/test_util.py | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/cloudinit/tests/test_util.py b/cloudinit/tests/test_util.py index f4f95e92..64ed82ea 100644 --- a/cloudinit/tests/test_util.py +++ b/cloudinit/tests/test_util.py @@ -387,6 +387,11 @@ class TestUdevadmSettle(CiTestCase):  @mock.patch('os.path.exists')  class TestGetLinuxDistro(CiTestCase): +    def setUp(self): +        # python2 has no lru_cache, and therefore, no cache_clear() +        if hasattr(util.get_linux_distro, "cache_clear"): +            util.get_linux_distro.cache_clear() +      @classmethod      def os_release_exists(self, path):          """Side effect function""" @@ -399,6 +404,12 @@ class TestGetLinuxDistro(CiTestCase):          if path == '/etc/redhat-release':              return 1 +    @classmethod +    def freebsd_version_exists(self, path): +        """Side effect function """ +        if path == '/bin/freebsd-version': +            return 1 +      @mock.patch('cloudinit.util.load_file')      def test_get_linux_distro_quoted_name(self, m_os_release, m_path_exists):          """Verify we get the correct name if the os-release file has @@ -417,6 +428,14 @@ class TestGetLinuxDistro(CiTestCase):          dist = util.get_linux_distro()          self.assertEqual(('ubuntu', '16.04', 'xenial'), dist) +    @mock.patch('cloudinit.util.subp') +    def test_get_linux_freebsd(self, m_subp, m_path_exists): +        """Verify we get the correct name and release name on FreeBSD.""" +        m_path_exists.side_effect = TestGetLinuxDistro.freebsd_version_exists +        m_subp.return_value = ("12.0-RELEASE-p10\n", '') +        dist = util.get_linux_distro() +        self.assertEqual(('freebsd', '12.0-RELEASE-p10', ''), dist) +      @mock.patch('cloudinit.util.load_file')      def test_get_linux_centos6(self, m_os_release, m_path_exists):          """Verify we get the correct name and release name on CentOS 6.""" | 
