-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest_update.py
31 lines (28 loc) · 956 Bytes
/
test_update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
"""This module tests the update module"""
import getpass
import builtins
import unittest
import mock
from libpkpass.commands.cli import Cli
from libpkpass.errors import DecryptionError
from .basetest.basetest import patch_args
class UpdateTests(unittest.TestCase):
"""This class tests the update class"""
def test_update_success(self):
"""Test a successful update of a password"""
ret = True
try:
with patch_args(
subparser_name="update",
identity="r3",
nopassphrase="true",
pwname="gentest",
no_cache=True,
):
with mock.patch.object(builtins, "input", lambda _: "y"):
with mock.patch.object(getpass, "getpass", lambda _: "y"):
"".join(Cli().run())
except DecryptionError:
ret = False
self.assertTrue(ret)