How to use the piicatcher.explorer.files.FileExplorer function in piicatcher

To help you get started, we’ve selected a few piicatcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tokern / piicatcher / tests / test_file_explorer.py View on Github external
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)
github tokern / piicatcher / tests / test_file_explorer.py View on Github external
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()
github tokern / piicatcher / tests / test_file_explorer.py View on Github external
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")
github tokern / piicatcher / tests / test_file_explorer.py View on Github external
def testDirectory(self):
        explorer = FileExplorer(
            Namespace(path="tests/samples", catalog={"format": "ascii_table"})
        )
        explorer.scan()
        result = explorer.get_dict()
        self._check(result)
github tokern / piicatcher / piicatcher / explorer / files.py View on Github external
def cli(ctx, path):
    ns = Namespace(path=path, catalog=ctx.obj["catalog"])

    FileExplorer.dispatch(ns)