mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-22 05:09:12 +00:00
unit tests: use f-strings (#10993)
This commit is contained in:
parent
e177d1e61a
commit
efad7a0d38
25 changed files with 54 additions and 78 deletions
|
|
@ -62,7 +62,7 @@ class MockBitwardenSecretsManager(BitwardenSecretsManager):
|
|||
else:
|
||||
# This should never happen unless there's an error in the test MOCK_SECRETS.
|
||||
# The real Bitwarden Secrets Manager assigns each secret a unique ID.
|
||||
raise ValueError("More than 1 secret found with id: '{0}'. Impossible!".format(secret_id))
|
||||
raise ValueError(f"More than 1 secret found with id: '{secret_id}'. Impossible!")
|
||||
|
||||
return out, err, rc
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@ class FakeEtcd3Client(MagicMock):
|
|||
|
||||
def get_prefix(self, key):
|
||||
for i in range(1, 4):
|
||||
yield self.get('{0}_{1}'.format(key, i))
|
||||
yield self.get(f'{key}_{i}')
|
||||
|
||||
def get(self, key):
|
||||
return ("{0} value".format(key), FakeKVMetadata(key, None))
|
||||
return (f"{key} value", FakeKVMetadata(key, None))
|
||||
|
||||
|
||||
class TestLookupModule(unittest.TestCase):
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class MockLPass(LPass):
|
|||
|
||||
field_group = show_p.add_mutually_exclusive_group(required=True)
|
||||
for field in MOCK_ENTRIES[0].keys():
|
||||
field_group.add_argument("--{0}".format(field), default=False, action='store_true')
|
||||
field_group.add_argument(f"--{field}", default=False, action='store_true')
|
||||
field_group.add_argument('--field', default=None)
|
||||
show_p.add_argument('selector', help='Unique Name or ID')
|
||||
|
||||
|
|
@ -73,8 +73,7 @@ class MockLPass(LPass):
|
|||
|
||||
if args.subparser_name == 'show':
|
||||
if self._mock_logged_out:
|
||||
return mock_exit(error='Error: Could not find decryption key.' +
|
||||
' Perhaps you need to login with `lpass login`.', rc=1)
|
||||
return mock_exit(error="Error: Could not find decryption key. Perhaps you need to login with `lpass login`.", rc=1)
|
||||
|
||||
if self._mock_disconnected:
|
||||
return mock_exit(error='Error: Couldn\'t resolve host name.', rc=1)
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ def test_op_set_token_with_config(op_fixture, mocker, request):
|
|||
op = request.getfixturevalue(op_fixture)
|
||||
token = "F5417F77529B41B595D7F9D6F76EC057"
|
||||
mocker.patch("os.path.isfile", return_value=True)
|
||||
mocker.patch.object(op._cli, "signin", return_value=(0, token + "\n", ""))
|
||||
mocker.patch.object(op._cli, "signin", return_value=(0, f"{token}\n", ""))
|
||||
|
||||
op.set_token()
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ def test_op_set_token_without_config(op_fixture, request, mocker):
|
|||
token = "B988E8A2680A4A348962751A96861FA1"
|
||||
mocker.patch("os.path.isfile", return_value=False)
|
||||
mocker.patch.object(op._cli, "signin", return_value=(99, "", ""))
|
||||
mocker.patch.object(op._cli, "full_signin", return_value=(0, token + "\n", ""))
|
||||
mocker.patch.object(op._cli, "full_signin", return_value=(0, f"{token}\n", ""))
|
||||
|
||||
op.set_token()
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ TSS_IMPORT_PATH = 'ansible_collections.community.general.plugins.lookup.tss'
|
|||
|
||||
|
||||
def make_absolute(name):
|
||||
return '.'.join([TSS_IMPORT_PATH, name])
|
||||
return f"{TSS_IMPORT_PATH}.{name}"
|
||||
|
||||
|
||||
class SecretServerError(Exception):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue