-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli_test.py
executable file
·66 lines (59 loc) · 1.3 KB
/
cli_test.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/python
import unittest
import json
import sys
import configparser
from cli import CLI
class MockCLI(CLI):
def initUserConfig(self):
self.config = configparser.SafeConfigParser()
self.config.add_section("server")
class TestCLI(unittest.TestCase):
def testCLI(self):
cli = MockCLI(
[
"-d",
"-u",
"admin",
"-p",
"password",
"export-user-encrypted-private-key",
"admin",
"unittest.key",
]
)
cli.initUserConfig()
cli.parse()
cli.init()
cli.login()
cli.run()
cli.args = [
"-d",
"-u",
"admin",
"-p",
"password",
"-k",
"unittest.key",
"create-secret",
]
cli.initUserConfig()
cli.parse()
cli.login()
cli.run()
cli.args = [
"-d",
"-u",
"admin",
"-p",
"password",
"-k",
"unittest.key",
"get-my-secrets",
]
cli.initUserConfig()
cli.parse()
cli.login()
cli.run()
if __name__ == "__main__":
unittest.main()