summaryrefslogtreecommitdiffstats
path: root/tests/test_application_name.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:29:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 05:29:33 +0000
commit649543d4c7ac623375e6bb0084fd415ad47d6549 (patch)
tree01c930bf54ae05bd6fb271c7161086f0eaf4da47 /tests/test_application_name.py
parentAdding upstream version 4.0.1. (diff)
downloadpgcli-upstream.tar.xz
pgcli-upstream.zip
Adding upstream version 4.1.0.upstream/4.1.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/test_application_name.py')
-rw-r--r--tests/test_application_name.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_application_name.py b/tests/test_application_name.py
new file mode 100644
index 0000000..5fac5b2
--- /dev/null
+++ b/tests/test_application_name.py
@@ -0,0 +1,17 @@
+from unittest.mock import patch
+
+from click.testing import CliRunner
+
+from pgcli.main import cli
+from pgcli.pgexecute import PGExecute
+
+
+def test_application_name_in_env():
+ runner = CliRunner()
+ app_name = "wonderful_app"
+ with patch.object(PGExecute, "__init__") as mock_pgxecute:
+ runner.invoke(
+ cli, ["127.0.0.1:5432/hello", "user"], env={"PGAPPNAME": app_name}
+ )
+ kwargs = mock_pgxecute.call_args.kwargs
+ assert kwargs.get("application_name") == app_name