Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions test/pytests/test_main_modes_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,26 @@ def run(self, text: str) -> Iterator[SQLResult]:
assert any('reconnection failed' in msg for msg in cli.echo_calls)


def test_one_iteration_enters_sandbox_mode_on_must_change_password_error(monkeypatch: pytest.MonkeyPatch) -> None:
patch_repl_runtime_defaults(monkeypatch)

class FakeSQLExecute:
dbname = 'db'
connection_id = 0

def run(self, text: str) -> Iterator[SQLResult]:
raise pymysql.OperationalError(repl_mode.ER_MUST_CHANGE_PASSWORD, 'must change password')

cli = make_repl_cli(FakeSQLExecute())

repl_mode._one_iteration(cli, repl_mode.ReplState(), 'SELECT 1')

assert cli.sandbox_mode is True
assert any('ERROR 1820' in msg for msg in cli.echo_calls)
assert cli.query_history[-1].query == 'SELECT 1'
assert cli.query_history[-1].successful is False


def test_one_iteration_covers_redirect_destructive_success_refresh_and_logfile(monkeypatch: pytest.MonkeyPatch) -> None:
patch_repl_runtime_defaults(monkeypatch)

Expand Down
Loading