Skip to content

Commit

Permalink
test: fix test_copy_dir for coverage test (#4204)
Browse files Browse the repository at this point in the history
- The test_copy_dir is failed in #4200 due to "Mock()" is used and
  passed into the coverage module. Changes to use `return_value`
  instead of Mock() directly.

Signed-off-by: Xiangce Liu <[email protected]>
  • Loading branch information
xiangce authored Sep 2, 2024
1 parent a9d50f6 commit 30d1ce3
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions insights/tests/client/test_archive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import time
from insights.client.archive import InsightsArchive
from insights.client.config import InsightsConfig
from mock.mock import patch, Mock, call
from unittest import TestCase
from pytest import raises
Expand Down Expand Up @@ -220,16 +221,16 @@ def test_get_full_archive_path(self, create_archive_dir, cleanup, _, __):
archive.get_full_archive_path('test')
create_archive_dir.assert_called_once()

@patch('insights.client.archive.os.path.join', return_value=test_archive_dir)
@patch('insights.client.archive.os.path.isdir', return_value=False)
@patch('insights.client.archive.shutil.copytree', return_value=None)
@patch('insights.client.archive.InsightsArchive.cleanup_previous_archive', return_value=None)
@patch('insights.client.archive.InsightsArchive.create_archive_dir', return_value=test_archive_dir)
@patch('insights.client.archive.os.path.join', Mock())
@patch('insights.client.archive.os.path.isdir', Mock())
@patch('insights.client.archive.shutil.copytree', Mock())
@patch('insights.client.archive.InsightsArchive.cleanup_previous_archive', Mock())
def test_copy_dir(self, create_archive_dir, _, __):
def test_copy_dir(self, create_archive_dir, _1, _2, _3, _4, _5, _6):
'''
Verify create_archive_dir is called when calling copy_dir
'''
archive = InsightsArchive(Mock())
archive = InsightsArchive(InsightsConfig())
archive.copy_dir('test')
create_archive_dir.assert_called_once()

Expand Down

0 comments on commit 30d1ce3

Please sign in to comment.