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)
Ejemplo n.º 2
0
 def testFile(self):
     explorer = FileExplorer(
         Namespace(path="tests/samples/sample-data.csv",
                   catalog={"format": "ascii_table"}))
     explorer.scan()
     result = explorer.get_dict()
     self.assertEqual(len(result["files"]), 1)
     self.assertEqual(result["files"][0]["Mime/Type"], "text/plain")
     self.assertEqual(result["files"][0]["path"],
                      "tests/samples/sample-data.csv")
     self.assertEqual(len(result["files"][0]["pii"]), 5)
Ejemplo n.º 3
0
 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', output_format='ascii_table'))
                 mock_scan_method.assert_called_once()
                 mock_tabular_method.assert_called_once()
                 MockTablePrint.table.assert_called_once()
 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()
Ejemplo n.º 5
0
 def testDirectory(self):
     explorer = FileExplorer(
         Namespace(path="tests/samples", catalog={"format": "ascii_table"}))
     explorer.scan()
     result = explorer.get_dict()
     self.assertEqual(len(result["files"]), 2)
     self.assertEqual(result["files"][0]["Mime/Type"], "application/gzip")
     self.assertEqual(result["files"][0]["path"],
                      "tests/samples/sample-data-2.csv.gz")
     self.assertEqual(len(result["files"][1]["pii"]), 5)
     self.assertEqual(result["files"][1]["Mime/Type"], "text/plain")
     self.assertEqual(result["files"][1]["path"],
                      "tests/samples/sample-data.csv")
     self.assertEqual(len(result["files"][1]["pii"]), 5)
Ejemplo n.º 6
0
    def setUpClass(cls):
        cls.explorer = FileExplorer("/tmp")
        f1 = File("/tmp/1", "text/plain")
        f1._pii.add(PiiTypes.BIRTH_DATE)

        f2 = File("/tmp/2", "application/pdf")
        f2._pii.add(PiiTypes.UNSUPPORTED)

        cls.explorer._files.append(f1)
        cls.explorer._files.append(f2)
Ejemplo n.º 7
0
 def testFile(self):
     explorer = FileExplorer("tests/samples/sample-data.csv")
     explorer.scan()
     result = explorer.get_dict()
     self._check(result)
Ejemplo n.º 8
0
 def testDirectory(self):
     explorer = FileExplorer("tests/samples")
     explorer.scan()
     result = explorer.get_dict()
     self._check(result)
Ejemplo n.º 9
0
 def testDirectory(self):
     explorer = FileExplorer(
         Namespace(path="tests/samples", catalog={'format': 'ascii_table'}))
     explorer.scan()
     result = explorer.get_dict()
     self._check(result)