Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
yengliong93 committed Oct 29, 2024
1 parent d540134 commit 511312c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions inbm-lib/tests/unit/inbm_common_lib/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,17 @@ def test_create_file_with_contents_successfully(self) -> None:
self.fail(f"Unexpected exception raised during test: {e}")

@patch('builtins.open', new_callable=mock_open, read_data='IMAGE_BUILD_DATE="20241026100955"')
def test_get_image_build_date_successfully(self, mock_open: Mock) -> None:
@patch('os.path.exists', return_value=True)
def test_get_image_build_date_successfully(self, mock_exist: Mock, mock_open: Mock) -> None:
try:
self.assertEqual(get_image_build_date(), "20241026100955")
except IOError as e:
self.fail(f"Unexpected exception raised during test: {e}")
mock_open.assert_called_once_with('/etc/image-id', 'r')

@patch('builtins.open', new_callable=mock_open, read_data='')
def test_get_image_build_date_with_no_version_found(self, mock_open: Mock) -> None:
@patch('os.path.exists', return_value=True)
def test_get_image_build_date_with_no_version_found(self, mock_exist: Mock, mock_open: Mock) -> None:
try:
self.assertEqual(get_image_build_date(), UNKNOWN)
except IOError as e:
Expand Down

0 comments on commit 511312c

Please sign in to comment.