Skip to content

Commit dc4151d

Browse files
committed
Move test of parse_args() as a Python unit test
So as to isolate the test on --help in the doctest to helper forthcoming changes.
1 parent 7cd125e commit dc4151d

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

tests/test_cli.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pgactivity import cli
2+
3+
4+
def test_parser() -> None:
5+
parser = cli.get_parser()
6+
ns = parser.parse_args(
7+
["--no-db-size", "-w", "-p", "5433", "--no-pid", "--no-app-name"]
8+
)
9+
assert vars(ns) == {
10+
"profile": None,
11+
"blocksize": 4096,
12+
"rds": False,
13+
"output": None,
14+
"dbsize": False,
15+
"tempfiles": True,
16+
"walreceiver": True,
17+
"wrap_query": True,
18+
"durationmode": "1",
19+
"minduration": 0,
20+
"filters": [],
21+
"debug_file": None,
22+
"help": False,
23+
"connection_string": "",
24+
"host": None,
25+
"port": "5433",
26+
"username": None,
27+
"dbname": None,
28+
"pid": False,
29+
"database": True,
30+
"user": True,
31+
"client": True,
32+
"cpu": True,
33+
"mem": True,
34+
"read": True,
35+
"write": True,
36+
"time": True,
37+
"wait": True,
38+
"appname": False,
39+
"header_show_instance": None,
40+
"header_show_system": None,
41+
"header_show_workers": None,
42+
"hide_queries_in_logs": False,
43+
"refresh": 2,
44+
}

tests/test_cli.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,3 @@ an URI as described in the PostgreSQL documentation. The parsing is delegated
7878
to the libpq: different versions of the client library may support different
7979
formats or parameters (for example, connection URIs are only supported from
8080
libpq 9.2).
81-
82-
>>> ns = parser.parse_args(["--no-db-size", "-w", "-p", "5433", "--no-pid", "--no-app-name"])
83-
>>> vars(ns)
84-
{'profile': None, 'blocksize': 4096, 'rds': False, 'output': None, 'dbsize': False, 'tempfiles': True, 'walreceiver': True, 'wrap_query': True, 'durationmode': '1', 'minduration': 0, 'filters': [], 'debug_file': None, 'help': False, 'connection_string': '', 'host': None, 'port': '5433', 'username': None, 'dbname': None, 'pid': False, 'database': True, 'user': True, 'client': True, 'cpu': True, 'mem': True, 'read': True, 'write': True, 'time': True, 'wait': True, 'appname': False, 'header_show_instance': None, 'header_show_system': None, 'header_show_workers': None, 'hide_queries_in_logs': False, 'refresh': 2}

0 commit comments

Comments
 (0)