mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-07 00:44:01 -07:00
[PR #6669/74ffb295 backport][stable-7] rhsm_release: improve the execution of subscription-manager (#6674)
rhsm_release: improve the execution of subscription-manager (#6669)
- pass the arguments to run_command() directly as list, rather than
joining the arguments to string, which run_command() will need to
split again
- disable the expansions of variables, as there are none
Adapt the unit test to the different way run_command() is called,
factorizing the kwargs for run_command() so there is less repetition.
There should be no behaviour changes.
(cherry picked from commit 74ffb29573
)
Co-authored-by: Pino Toscano <ptoscano@redhat.com>
This commit is contained in:
parent
396b94183d
commit
f986b97c9a
3 changed files with 15 additions and 8 deletions
|
@ -14,6 +14,8 @@ from ansible_collections.community.general.tests.unit.plugins.modules.utils impo
|
|||
class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
||||
module = rhsm_release
|
||||
|
||||
SUBMAN_KWARGS = dict(check_rc=True, expand_user_and_vars=False)
|
||||
|
||||
def setUp(self):
|
||||
super(RhsmRepositoryReleaseModuleTestCase, self).setUp()
|
||||
|
||||
|
@ -63,8 +65,8 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
self.assertTrue(result['changed'])
|
||||
self.assertEqual('7.5', result['current_release'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call('/testbin/subscription-manager release --show', check_rc=True),
|
||||
call('/testbin/subscription-manager release --set 7.5', check_rc=True),
|
||||
call(['/testbin/subscription-manager', 'release', '--show'], **self.SUBMAN_KWARGS),
|
||||
call(['/testbin/subscription-manager', 'release', '--set', '7.5'], **self.SUBMAN_KWARGS),
|
||||
])
|
||||
|
||||
def test_release_set_idempotent(self):
|
||||
|
@ -81,7 +83,7 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
self.assertFalse(result['changed'])
|
||||
self.assertEqual('7.5', result['current_release'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call('/testbin/subscription-manager release --show', check_rc=True),
|
||||
call(['/testbin/subscription-manager', 'release', '--show'], **self.SUBMAN_KWARGS),
|
||||
])
|
||||
|
||||
def test_release_unset(self):
|
||||
|
@ -100,8 +102,8 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
self.assertTrue(result['changed'])
|
||||
self.assertIsNone(result['current_release'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call('/testbin/subscription-manager release --show', check_rc=True),
|
||||
call('/testbin/subscription-manager release --unset', check_rc=True),
|
||||
call(['/testbin/subscription-manager', 'release', '--show'], **self.SUBMAN_KWARGS),
|
||||
call(['/testbin/subscription-manager', 'release', '--unset'], **self.SUBMAN_KWARGS),
|
||||
])
|
||||
|
||||
def test_release_unset_idempotent(self):
|
||||
|
@ -118,7 +120,7 @@ class RhsmRepositoryReleaseModuleTestCase(ModuleTestCase):
|
|||
self.assertFalse(result['changed'])
|
||||
self.assertIsNone(result['current_release'])
|
||||
self.module_main_command.assert_has_calls([
|
||||
call('/testbin/subscription-manager release --show', check_rc=True),
|
||||
call(['/testbin/subscription-manager', 'release', '--show'], **self.SUBMAN_KWARGS),
|
||||
])
|
||||
|
||||
def test_release_insane(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue