-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The application_name to be used when connecting to a database can now be specified as a command line argument (--application-name) or be taken directly from environment variables (PGAPPNAME). It still defaults to 'pgcli' when not specified. Closes #1421.
- Loading branch information
1 parent
f2156b3
commit e2ff38d
Showing
4 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |