test_sqlite_controller.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:PlasoScaffolder 作者: ClaudiaSaxer 项目源码 文件源码
def testTestPathIfNotExisting(self):
    """test method after getting the source path from the user"""
    with tempfile.TemporaryDirectory() as tmpdir:
      path = os.path.join(tmpdir, 'testfile')
      pathlib.Path(path).touch()
      wrongPath = os.path.join(tmpdir, 'testpath')
      validPath = os.path.join(tmpdir, 'testpathvalid')

      output_handler = output_handler_file.OutputHandlerFile(
          path, file_handler.FileHandler(), prompt_error=validPath)
      plugin_helper = fake_sqlite_plugin_helper.FakeSQLitePluginHelper(
          file_exists=False, change_bool_after_every_call_file_exists=True)
      controller = sqlite_controller.SQLiteController(output_handler,
                                                      plugin_helper)
      actual_path = controller.TestPath(None, None, wrongPath)
      expected = 'File does not exists. Choose another.'
      actual = self._ReadFromFile(path)
      self.assertEqual(expected, actual)
      self.assertEqual(validPath, actual_path)
      # close connection so the temp file can be deleted before the program
      #   circle is finished
      controller._query_execution._connection.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号