@@ -118,33 +118,6 @@ def test_run_from_cli_args_rejects_conflicting_format_flags(
118118 assert secho_calls == [(message , {'err' : True , 'fg' : 'red' })]
119119
120120
121- def test_run_from_cli_args_uses_deprecated_mysql_unix_port_and_database_alias (
122- monkeypatch : pytest .MonkeyPatch ,
123- ) -> None :
124- cli_args = make_cli_args ()
125- cli_args .database = 'prod'
126- client = DummyMyCli (
127- config = {
128- ** default_config (),
129- 'alias_dsn' : {'prod' : 'mysql://dsn_user:dsn_pass@dsn_host:3307/dsn_db' },
130- }
131- )
132- secho_calls : list [str ] = []
133- monkeypatch .setenv ('MYSQL_UNIX_PORT' , '/tmp/mysql.sock' )
134- monkeypatch .setattr (cli_runner .click , 'secho' , lambda text , ** _kwargs : secho_calls .append (text ))
135-
136- run_with_client (monkeypatch , cli_args , client )
137-
138- assert client .dsn_alias == 'prod'
139- assert client .connect_calls [- 1 ]['database' ] == 'dsn_db'
140- assert client .connect_calls [- 1 ]['user' ] == 'dsn_user'
141- assert client .connect_calls [- 1 ]['passwd' ] == 'dsn_pass'
142- assert client .connect_calls [- 1 ]['host' ] == 'dsn_host'
143- assert client .connect_calls [- 1 ]['port' ] == 3307
144- assert client .connect_calls [- 1 ]['socket' ] == '/tmp/mysql.sock'
145- assert any ('MYSQL_UNIX_PORT environment variable is deprecated' in call for call in secho_calls )
146-
147-
148121def test_run_from_cli_args_reports_missing_dsn (monkeypatch : pytest .MonkeyPatch ) -> None :
149122 cli_args = make_cli_args ()
150123 cli_args .dsn = 'missing'
@@ -165,6 +138,26 @@ def test_run_from_cli_args_reports_missing_dsn(monkeypatch: pytest.MonkeyPatch)
165138 ]
166139
167140
141+ def test_run_from_cli_args_treats_database_as_dsn_alias (monkeypatch : pytest .MonkeyPatch ) -> None :
142+ cli_args = make_cli_args ()
143+ cli_args .database = 'prod'
144+ client = DummyMyCli (
145+ config = {
146+ ** default_config (),
147+ 'alias_dsn' : {'prod' : 'mysql://u:p@h/db' },
148+ }
149+ )
150+
151+ run_with_client (monkeypatch , cli_args , client )
152+
153+ assert client .dsn_alias == 'prod'
154+ connect_call = client .connect_calls [- 1 ]
155+ assert connect_call ['user' ] == 'u'
156+ assert connect_call ['passwd' ] == 'p'
157+ assert connect_call ['host' ] == 'h'
158+ assert connect_call ['database' ] == 'db'
159+
160+
168161def test_run_from_cli_args_maps_dsn_ssl_parameters (monkeypatch : pytest .MonkeyPatch ) -> None :
169162 cli_args = make_cli_args ()
170163 cli_args .dsn = (
0 commit comments