Skip to content

Commit

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

Signed-off-by: Mihaela Balutoiu <[email protected]>
  • Loading branch information
mihaelabalutoiu committed Mar 29, 2024
1 parent 3a56c87 commit 7237d4f
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions coriolis/tests/osmorphing/osdetect/test_amazon.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 amazon
from coriolis.osmorphing.osdetect import base
from coriolis.tests import test_base


class AmazonLinuxOSDetectToolsTestCase(test_base.CoriolisBaseTestCase):
"""Test suite for AmazonLinuxOSDetectTools class."""

@mock.patch.object(base.BaseLinuxOSDetectTools, '_get_os_release')
def test_detect_os(self, mock_get_os_release):
mock_get_os_release.return_value = {
"ID": "amzn",
"VERSION": mock.sentinel.version,
"NAME": "Amazon Linux"
}

expected_info = {
"os_type": amazon.constants.OS_TYPE_LINUX,
"distribution_name": amazon.AMAZON_DISTRO_NAME,
"release_version": mock.sentinel.version,
"friendly_release_name": "Amazon Linux %s" % mock.sentinel.version
}

amazon_os_detect_tools = amazon.AmazonLinuxOSDetectTools(
mock.sentinel.conn, mock.sentinel.os_root_dir,
mock.sentinel.operation_timeout)

result = amazon_os_detect_tools.detect_os()

mock_get_os_release.assert_called_once_with()

self.assertEqual(result, expected_info)

0 comments on commit 7237d4f

Please sign in to comment.