File: test_cli.py

package info (click to toggle)
pg-activity 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,144 kB
  • sloc: python: 3,902; sql: 1,067; sh: 5; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,341 bytes parent folder | download | duplicates (2)
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
from pgactivity import cli


def test_parser() -> None:
    parser = cli.get_parser()
    ns = parser.parse_args(
        ["--no-db-size", "-w", "-p", "5433", "--no-pid", "--no-app-name"]
    )
    assert vars(ns) == {
        "profile": None,
        "blocksize": 4096,
        "rds": False,
        "output": None,
        "dbsize": False,
        "tempfiles": None,
        "walreceiver": None,
        "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": None,
        "user": None,
        "client": None,
        "cpu": None,
        "mem": None,
        "read": None,
        "write": None,
        "time": None,
        "wait": None,
        "xmin": None,
        "appname": False,
        "header_show_instance": None,
        "header_show_system": None,
        "header_show_workers": None,
        "hide_queries_in_logs": False,
        "refresh": 2,
    }


def test_parser_flag_on() -> None:
    parser = cli.get_parser()
    ns = parser.parse_args(["--pid", "--no-app-name"])
    assert ns.pid is True
    assert ns.appname is False
    assert ns.wait is None