def testCreateSQLQueryModelWithUserInputWithExamplesAndOneDataExamples(self):
"""test method CreateEventModelWithUserInput with examples"""
fake_execution = fake_sqlite_query_execution.SQLQueryExecution(
sql_query_data.SQLQueryData(
has_error=False, data=['first'],
columns=[type('columns', (object,), {'sql_column': 'id'}),
type('columns', (object,), {'sql_column': 'name'})])
)
sql_query = 'SELECT id from Users'
name = 'Contact'
with tempfile.TemporaryDirectory() as tmpdir:
path = os.path.join(tmpdir, 'testfile')
pathlib.Path(path).touch()
output_handler = output_handler_file.OutputHandlerFile(
path, file_handler.FileHandler(),
confirm=True, confirm_amount_same=2, prompt_info=name)
plugin_helper = fake_sqlite_plugin_helper.FakeSQLitePluginHelper(
folder_exists=True)
controller = sqlite_controller.SQLiteController(output_handler,
plugin_helper)
controller.GetTimestamps = mock.MagicMock(return_value=([], []))
actual = controller._CreateSQLQueryModelWithUserInput(sql_query, True,
fake_execution)
prompt_output_actual = self._ReadFromFile(path)
prompt_output_expected = ('Your query output could look like this.'
'[\'id\', \'name\']'
'first'
'Do you want to add this query?'
'Do you want to name the query parse row: ?'
'Does the event need customizing?')
expected = sql_query_model.SQLQueryModel(sql_query, name, [], [], False,
0)
self.assertEqual(actual.name, '')
self.assertEqual(expected.query, actual.query)
self.assertEqual(prompt_output_expected, prompt_output_actual)
test_sqlite_controller.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录