Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_sqlite_dispatch(self):
with mock.patch(
"piicatcher.explorer.sqlite.SqliteExplorer.scan", autospec=True
) as mock_scan_method:
with mock.patch(
"piicatcher.explorer.sqlite.SqliteExplorer.get_tabular", autospec=True
) as mock_tabular_method:
with mock.patch(
"piicatcher.explorer.explorer.tableprint", autospec=True
) as mock_table_print:
SqliteExplorer.dispatch(
Namespace(
path="connection",
list_all=None,
catalog={"format": "ascii_table"},
scan_type=None,
include_schema=(),
exclude_schema=(),
include_table=(),
exclude_table=(),
)
)
mock_scan_method.assert_called_once()
mock_tabular_method.assert_called_once()
mock_table_print.table.assert_called_once()
def temp_sqlite(request, tmpdir_factory):
temp_dir = tmpdir_factory.mktemp("sqlite_test")
sqlite_path = temp_dir.join("sqldb")
explorer = SqliteExplorer(
Namespace(
path=sqlite_path,
catalog=None,
include_schema=(),
exclude_schema=(),
include_table=(),
exclude_table=(),
)
)
request.cls.explorer = explorer
request.cls.path = str(sqlite_path)
def finalizer():
explorer.get_connection().close()
rmtree(temp_dir)
def test_sqlite(self):
self.assertEqual(
'select "c1","c2" from t1',
SqliteExplorer._get_select_query(
self.schema,
self.schema.get_children()[0],
self.schema.get_children()[0].get_children(),
),
def __init__(self, ns):
super(SqliteExplorer, self).__init__(ns)
self.path = ns.path
def _get_context_manager(self):
return SqliteExplorer.CursorContextManager(self.get_connection())
def factory(cls, ns):
logging.debug("Sqlite Factory entered")
return SqliteExplorer(ns)
exclude_table=exclude_table,
)
if output_format is not None or output is not None:
logging.warning(
"--output-format and --output is deprecated. "
"Please use --catalog-format and --catalog-file"
)
if output_format is not None:
args.catalog["format"] = output_format
if output is not None:
args.catalog["file"] = output
SqliteExplorer.dispatch(args)