Skip to content

Commit

Permalink
Add unit tests for osmorphing.osdetect.ubuntu.py
Browse files Browse the repository at this point in the history
module

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
  • Loading branch information
mihaelabalutoiu committed Apr 19, 2024
1 parent 61cf9e1 commit cd4b4af
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions coriolis/tests/osmorphing/osdetect/test_ubuntu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024 Cloudbase Solutions Srl
# All Rights Reserved.

from unittest import mock

from coriolis.osmorphing.osdetect import base
from coriolis.osmorphing.osdetect import ubuntu
from coriolis.tests import test_base


class UbuntuOSDetectToolsTestCase(test_base.CoriolisBaseTestCase):
"""Test suite for the UbuntuOSDetectTools class."""

@mock.patch.object(base.BaseLinuxOSDetectTools, '_read_config_file')
def test_detect_os(self, mock_read_config_file):
mock_read_config_file.return_value = {
"DISTRIB_ID": "Ubuntu",
"DISTRIB_RELEASE": mock.sentinel.version
}

expected_info = {
"os_type": ubuntu.constants.OS_TYPE_LINUX,
"distribution_name": ubuntu.UBUNTU_DISTRO_IDENTIFIER,
"release_version": mock.sentinel.version,
"friendly_release_name": "Ubuntu %s" % (
mock.sentinel.version)
}

ubuntu_os_detect_tools = ubuntu.UbuntuOSDetectTools(
mock.sentinel.conn, mock.sentinel.os_root_dir,
mock.sentinel.operation_timeout)

result = ubuntu_os_detect_tools.detect_os()

mock_read_config_file.assert_called_once_with(
"etc/lsb-release", check_exists=True)

self.assertEqual(result, expected_info)

0 comments on commit cd4b4af

Please sign in to comment.