2019-12-15 07:13:33 +08:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from django.db.backends.sqlite3.client import DatabaseClient
|
|
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
|
|
|
|
|
|
class SqliteDbshellCommandTestCase(SimpleTestCase):
|
2020-10-05 06:25:29 +08:00
|
|
|
def settings_to_cmd_args_env(self, settings_dict, parameters=None):
|
2020-04-14 15:56:40 +08:00
|
|
|
if parameters is None:
|
|
|
|
parameters = []
|
2020-10-05 06:25:29 +08:00
|
|
|
return DatabaseClient.settings_to_cmd_args_env(settings_dict, parameters)
|
2019-12-15 07:13:33 +08:00
|
|
|
|
|
|
|
def test_path_name(self):
|
2020-10-05 06:25:29 +08:00
|
|
|
self.assertEqual(
|
|
|
|
self.settings_to_cmd_args_env({'NAME': Path('test.db.sqlite3')}),
|
2021-01-19 15:35:16 +08:00
|
|
|
(['sqlite3', Path('test.db.sqlite3')], None),
|
2020-10-05 06:25:29 +08:00
|
|
|
)
|
2020-04-14 15:56:40 +08:00
|
|
|
|
|
|
|
def test_parameters(self):
|
2020-10-05 06:25:29 +08:00
|
|
|
self.assertEqual(
|
|
|
|
self.settings_to_cmd_args_env({'NAME': 'test.db.sqlite3'}, ['-help']),
|
|
|
|
(['sqlite3', 'test.db.sqlite3', '-help'], None),
|
|
|
|
)
|