2020-04-14 10:18:58 +00:00
|
|
|
from unittest import mock
|
|
|
|
|
|
|
|
from django.core.management import call_command
|
|
|
|
from django.core.management.base import CommandError
|
|
|
|
from django.db import connection
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class DbshellCommandTestCase(SimpleTestCase):
|
|
|
|
def test_command_missing(self):
|
|
|
|
msg = (
|
2022-02-03 19:24:19 +00:00
|
|
|
"You appear not to have the %r program installed or on your path."
|
2020-04-14 10:18:58 +00:00
|
|
|
% connection.client.executable_name
|
|
|
|
)
|
|
|
|
with self.assertRaisesMessage(CommandError, msg):
|
2022-02-03 19:24:19 +00:00
|
|
|
with mock.patch("subprocess.run", side_effect=FileNotFoundError):
|
|
|
|
call_command("dbshell")
|