mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 01:55:51 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -7,7 +7,7 @@ from __future__ import annotations
|
|||
import sys
|
||||
import unittest
|
||||
|
||||
from ansible_collections.community.general.plugins.module_utils.hwc_utils import (HwcModuleException, navigate_value)
|
||||
from ansible_collections.community.general.plugins.module_utils.hwc_utils import HwcModuleException, navigate_value
|
||||
|
||||
|
||||
class HwcUtilsTestCase(unittest.TestCase):
|
||||
|
|
@ -20,28 +20,24 @@ class HwcUtilsTestCase(unittest.TestCase):
|
|||
|
||||
def test_navigate_value(self):
|
||||
value = {
|
||||
'foo': {
|
||||
'quiet': {
|
||||
'tree': 'test',
|
||||
"trees": [0, 1]
|
||||
},
|
||||
"foo": {
|
||||
"quiet": {"tree": "test", "trees": [0, 1]},
|
||||
}
|
||||
}
|
||||
|
||||
self.assertEqual(navigate_value(value, ["foo", "quiet", "tree"]),
|
||||
"test")
|
||||
self.assertEqual(navigate_value(value, ["foo", "quiet", "tree"]), "test")
|
||||
|
||||
self.assertEqual(
|
||||
navigate_value(value, ["foo", "quiet", "trees"],
|
||||
{"foo.quiet.trees": 1}),
|
||||
1)
|
||||
self.assertEqual(navigate_value(value, ["foo", "quiet", "trees"], {"foo.quiet.trees": 1}), 1)
|
||||
|
||||
self.assertRaisesRegex(HwcModuleException,
|
||||
r".* key\(q\) is not exist in dict",
|
||||
navigate_value, value, ["foo", "q", "tree"])
|
||||
self.assertRaisesRegex(
|
||||
HwcModuleException, r".* key\(q\) is not exist in dict", navigate_value, value, ["foo", "q", "tree"]
|
||||
)
|
||||
|
||||
self.assertRaisesRegex(HwcModuleException,
|
||||
r".* the index is out of list",
|
||||
navigate_value, value,
|
||||
["foo", "quiet", "trees"],
|
||||
{"foo.quiet.trees": 2})
|
||||
self.assertRaisesRegex(
|
||||
HwcModuleException,
|
||||
r".* the index is out of list",
|
||||
navigate_value,
|
||||
value,
|
||||
["foo", "quiet", "trees"],
|
||||
{"foo.quiet.trees": 2},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue