mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-27 10:40:22 -07:00
parted: fix regex for version match and partition size output (#1695)
* Fix 2 regex in parted related to parted version string and to parsing partition size output. * Added changelog fragment. * Updated changelog as per recommendation. * Fix the regex matching the parted version. The space character at the end of the string may or may not be always present * provided sample version output and corrected regex to match * add/correct changelog fragment * split parted_version function to allow creating a test unit * test unit for parted version info * ansible-test sanity fixes * review fix * Update changelogs/fragments/1695-parted-updatedregex.yaml Co-authored-by: Felix Fontein <felix@fontein.de> * comment fixes * better function name * Update plugins/modules/system/parted.py Co-authored-by: Felix Fontein <felix@fontein.de> * comment fixes Co-authored-by: Claude Robitaille <claude@cbcr.me> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ae8edc02e1
commit
43da5b88db
3 changed files with 66 additions and 14 deletions
|
@ -6,6 +6,7 @@ __metaclass__ = type
|
|||
|
||||
from ansible_collections.community.general.tests.unit.compat.mock import patch, call
|
||||
from ansible_collections.community.general.plugins.modules.system import parted as parted_module
|
||||
from ansible_collections.community.general.plugins.modules.system.parted import parse_parted_version
|
||||
from ansible_collections.community.general.plugins.modules.system.parted import parse_partition_info
|
||||
from ansible_collections.community.general.tests.unit.plugins.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args
|
||||
|
||||
|
@ -17,6 +18,32 @@ BYT;
|
|||
2:106MB:368MB:262MB:ext2::;
|
||||
3:368MB:256061MB:255692MB:::;"""
|
||||
|
||||
parted_version_info = {"""
|
||||
parted (GNU parted) 3.3
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
|
||||
""": (3, 3, 0), """
|
||||
parted (GNU parted) 3.4.5
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
|
||||
""": (3, 4, 5), """
|
||||
parted (GNU parted) 3.3.14-dfc61
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
|
||||
Written by <http://git.debian.org/?p=parted/parted.git;a=blob_plain;f=AUTHORS>.
|
||||
""": (3, 3, 14)}
|
||||
|
||||
# corresponding dictionary after parsing by parse_partition_info
|
||||
parted_dict1 = {
|
||||
"generic": {
|
||||
|
@ -311,3 +338,8 @@ class TestParted(ModuleTestCase):
|
|||
})
|
||||
with patch('ansible_collections.community.general.plugins.modules.system.parted.get_device_info', return_value=parted_dict3):
|
||||
self.execute_module(changed=True)
|
||||
|
||||
def test_version_info(self):
|
||||
"""Test that the parse_parted_version returns the expected tuple"""
|
||||
for key, value in parted_version_info.items():
|
||||
self.assertEqual(parse_parted_version(key), value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue