From bda2bb7870026c8933ab18208006ea288816e6b8 Mon Sep 17 00:00:00 2001 From: Denis Laxalde Date: Tue, 8 Oct 2024 11:55:53 +0200 Subject: [PATCH] Adjust tests for Python 3.13 And use this version in CI. Also adjust the sample output of --help in README. --- .github/workflows/tests.yml | 3 +- README.md | 12 ++--- tests/test_cli_help.txt | 16 +++--- tests/test_cli_help_py312.txt | 92 +++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 tests/test_cli_help_py312.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 32c1aa06..c9dbf76a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: include: - python: "3.9" psycopg: "psycopg2" - - python: "3.12" + - python: "3.13" psycopg: "psycopg3" steps: - uses: actions/checkout@v4 @@ -18,6 +18,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} + allow-prereleases: true - name: Install tox run: pip install tox - name: Add fr_FR and zh_TW for test purposes diff --git a/README.md b/README.md index cba37d23..45241e8f 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ ex: pg_activity [options] [connection string] Configuration: - -P PROFILE, --profile PROFILE + -P, --profile PROFILE Configuration profile matching a PROFILE.conf file in ${XDG_CONFIG_HOME:~/.config}/pg_activity/ or /etc/pg_activity/, or a built-in profile. @@ -123,13 +123,11 @@ ex: Connection Options: connection string A valid connection string to the database, e.g.: 'host=HOSTNAME port=PORT user=USER dbname=DBNAME'. - -h HOSTNAME, --host HOSTNAME - Database server host or socket directory. - -p PORT, --port PORT Database server port. - -U USERNAME, --username USERNAME + -h, --host HOSTNAME Database server host or socket directory. + -p, --port PORT Database server port. + -U, --username USERNAME Database user name. - -d DBNAME, --dbname DBNAME - Database name to connect to. + -d, --dbname DBNAME Database name to connect to. Process table display options: These options may be used hide some columns from the processes table. diff --git a/tests/test_cli_help.txt b/tests/test_cli_help.txt index 1a750392..c335854b 100644 --- a/tests/test_cli_help.txt +++ b/tests/test_cli_help.txt @@ -1,7 +1,7 @@ >>> import sys >>> import pytest ->>> if sys.version_info < (3, 9): -... pytest.skip("only applies for Python version >= 3.9") +>>> if sys.version_info < (3, 13): +... pytest.skip("only applies for Python version >= 3.13") ... >>> from pgactivity import cli @@ -12,7 +12,7 @@ usage: pytest [options] [connection string] htop like application for PostgreSQL server activity monitoring. Configuration: - -P PROFILE, --profile PROFILE + -P, --profile PROFILE Configuration profile matching a PROFILE.conf file in ${XDG_CONFIG_HOME:~/.config}/pg_activity/ or /etc/pg_activity/, or a built-in profile. @@ -48,13 +48,11 @@ Options: Connection Options: connection string A valid connection string to the database, e.g.: 'host=HOSTNAME port=PORT user=USER dbname=DBNAME'. - -h HOSTNAME, --host HOSTNAME - Database server host or socket directory. - -p PORT, --port PORT Database server port. - -U USERNAME, --username USERNAME + -h, --host HOSTNAME Database server host or socket directory. + -p, --port PORT Database server port. + -U, --username USERNAME Database user name. - -d DBNAME, --dbname DBNAME - Database name to connect to. + -d, --dbname DBNAME Database name to connect to. Process table display options: These options may be used hide some columns from the processes table. diff --git a/tests/test_cli_help_py312.txt b/tests/test_cli_help_py312.txt new file mode 100644 index 00000000..89b3c215 --- /dev/null +++ b/tests/test_cli_help_py312.txt @@ -0,0 +1,92 @@ +>>> import sys +>>> import pytest +>>> if sys.version_info >= (3, 13): +... pytest.skip("only applies for Python version < 3.13") +... + +>>> from pgactivity import cli +>>> parser = cli.get_parser() +>>> parser.print_help() +usage: pytest [options] [connection string] + +htop like application for PostgreSQL server activity monitoring. + +Configuration: + -P PROFILE, --profile PROFILE + Configuration profile matching a PROFILE.conf file in + ${XDG_CONFIG_HOME:~/.config}/pg_activity/ or + /etc/pg_activity/, or a built-in profile. + +Options: + --blocksize BLOCKSIZE + Filesystem blocksize (default: 4096). + --rds Enable support for AWS RDS (implies --no-tempfiles and + filters out the rdsadmin database from space + calculation). + --output FILEPATH Store running queries as CSV. + --db-size, --no-db-size + Enable/disable total size of DB. + --tempfiles, --no-tempfiles + Enable/disable tempfile count and size. + --walreceiver, --no-walreceiver + Enable/disable walreceiver checks. + -w, --wrap-query Wrap query column instead of truncating. + --duration-mode DURATION_MODE + Duration mode. Values: 1-QUERY(default), + 2-TRANSACTION, 3-BACKEND. + --min-duration SECONDS + Don't display queries with smaller than specified + duration (in seconds). + --filter FIELD:REGEX Filter activities with a (case insensitive) regular + expression applied on selected fields. Known fields + are: dbname. + --debug-file DEBUG_FILE + Enable debug and write it to DEBUG_FILE. + --version show program's version number and exit. + --help Show this help message and exit. + +Connection Options: + connection string A valid connection string to the database, e.g.: + 'host=HOSTNAME port=PORT user=USER dbname=DBNAME'. + -h HOSTNAME, --host HOSTNAME + Database server host or socket directory. + -p PORT, --port PORT Database server port. + -U USERNAME, --username USERNAME + Database user name. + -d DBNAME, --dbname DBNAME + Database name to connect to. + +Process table display options: + These options may be used hide some columns from the processes table. + + --pid, --no-pid Enable/disable PID. + --database, --no-database + Enable/disable DATABASE. + --user, --no-user Enable/disable USER. + --client, --no-client + Enable/disable CLIENT. + --cpu, --no-cpu Enable/disable CPU%. + --mem, --no-mem Enable/disable MEM%. + --read, --no-read Enable/disable READ/s. + --write, --no-write Enable/disable WRITE/s. + --time, --no-time Enable/disable TIME+. + --wait, --no-wait Enable/disable W. + --app-name, --no-app-name + Enable/disable APP. + +Header display options: + --no-inst-info Hide instance information. + --no-sys-info Hide system information. + --no-proc-info Hide workers process information. + +Other display options: + --hide-queries-in-logs + Disable log_min_duration_statements and + log_min_duration_sample for pg_activity. + --refresh REFRESH Refresh rate. Values: 0.5, 1, 2, 3, 4, 5 (default: 2). + +The connection string can be in the form of a list of Key/Value parameters or +an URI as described in the PostgreSQL documentation. The parsing is delegated +to the libpq: different versions of the client library may support different +formats or parameters (for example, connection URIs are only supported from +libpq 9.2).