mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Correct unit tests and module fixes (#44488)
Cleanup of unit tests. Modules fixes in iapp_template nad profile_dns to support unit tests.
This commit is contained in:
parent
bda074d34e
commit
49f34fec13
21 changed files with 251 additions and 163 deletions
|
@ -115,6 +115,7 @@ try:
|
|||
from library.module_utils.network.f5.common import AnsibleF5Parameters
|
||||
from library.module_utils.network.f5.common import cleanup_tokens
|
||||
from library.module_utils.network.f5.common import f5_argument_spec
|
||||
from library.module_utils.network.f5.common import fq_name
|
||||
try:
|
||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
from f5.utils.iapp_parser import NonextantTemplateNameException
|
||||
|
@ -127,6 +128,7 @@ except ImportError:
|
|||
from ansible.module_utils.network.f5.common import AnsibleF5Parameters
|
||||
from ansible.module_utils.network.f5.common import cleanup_tokens
|
||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||
from ansible.module_utils.network.f5.common import fq_name
|
||||
try:
|
||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
from f5.utils.iapp_parser import NonextantTemplateNameException
|
||||
|
@ -163,8 +165,7 @@ class Parameters(AnsibleF5Parameters):
|
|||
if self._values['content'] is None:
|
||||
return None
|
||||
result = self._squash_template_name_prefix()
|
||||
if self._values['name']:
|
||||
result = self._replace_template_name(result)
|
||||
result = self._replace_template_name(result)
|
||||
return result
|
||||
|
||||
@property
|
||||
|
@ -206,7 +207,13 @@ class Parameters(AnsibleF5Parameters):
|
|||
:return string
|
||||
"""
|
||||
pattern = r'sys\s+application\s+template\s+[^ ]+'
|
||||
replace = 'sys application template {0}'.format(self._values['name'])
|
||||
|
||||
if self._values['name']:
|
||||
name = self._values['name']
|
||||
else:
|
||||
name = self._get_template_name()
|
||||
|
||||
replace = 'sys application template {0}'.format(fq_name(self.partition, name))
|
||||
return re.sub(pattern, replace, template)
|
||||
|
||||
def _get_template_name(self):
|
||||
|
@ -214,7 +221,7 @@ class Parameters(AnsibleF5Parameters):
|
|||
# using it in all cases to get the name of an iApp. So we'll use this
|
||||
# pattern for now and file a bug with the F5 SDK
|
||||
pattern = r'sys\s+application\s+template\s+(?P<path>\/[^\{}"\'*?|#]+\/)?(?P<name>[^\{}"\'*?|#]+)'
|
||||
matches = re.search(pattern, self.content)
|
||||
matches = re.search(pattern, self._values['content'])
|
||||
try:
|
||||
result = matches.group('name').strip()
|
||||
except IndexError:
|
||||
|
@ -392,6 +399,8 @@ class ModuleManager(object):
|
|||
result = output.commandResult
|
||||
if 'Syntax Error' in result:
|
||||
raise F5ModuleError(output.commandResult)
|
||||
if 'ERROR' in result:
|
||||
raise F5ModuleError(output.commandResult)
|
||||
|
||||
def remove(self):
|
||||
if self.module.check_mode:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue