Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testFile(self):
explorer = FileExplorer(
Namespace(
path="tests/samples/sample-data.csv", catalog={"format": "ascii_table"}
)
)
explorer.scan()
result = explorer.get_dict()
self._check(result)
def test_file_dispatch(self):
with mock.patch(
"piicatcher.explorer.files.FileExplorer.scan", autospec=True
) as mock_scan_method:
with mock.patch(
"piicatcher.explorer.files.FileExplorer.get_tabular", autospec=True
) as mock_tabular_method:
with mock.patch(
"piicatcher.explorer.files.tableprint", autospec=True
) as MockTablePrint:
FileExplorer.dispatch(
Namespace(path="/a/b/c", catalog={"format": "ascii_table"})
)
mock_scan_method.assert_called_once()
mock_tabular_method.assert_called_once()
MockTablePrint.table.assert_called_once()
explorer.scan()
result = explorer.get_dict()
self._check(result)
def testFile(self):
explorer = FileExplorer(
Namespace(
path="tests/samples/sample-data.csv", catalog={"format": "ascii_table"}
)
)
explorer.scan()
result = explorer.get_dict()
self._check(result)
class MockFileExplorer(FileExplorer):
def scan(self):
f1 = File("/tmp/1", "text/plain")
f1._pii.add(PiiTypes.BIRTH_DATE)
f2 = File("/tmp/2", "application/pdf")
f2._pii.add(PiiTypes.UNSUPPORTED)
self._files.append(f1)
self._files.append(f2)
@pytest.fixture(scope="module")
def namespace(request, tmpdir_factory):
temp_dir = tmpdir_factory.mktemp("file_explorer_test")
output_path = temp_dir.join("output.json")
fh = open(output_path, "w")
def testDirectory(self):
explorer = FileExplorer(
Namespace(path="tests/samples", catalog={"format": "ascii_table"})
)
explorer.scan()
result = explorer.get_dict()
self._check(result)
def cli(ctx, path):
ns = Namespace(path=path, catalog=ctx.obj["catalog"])
FileExplorer.dispatch(ns)