Ejemplo n.º 1
0
    def test_corrupt_cache_files(self):
        file_path = get_data_path(self.log_printer, "corrupt_file")
        with open(file_path, "wb") as f:
            f.write(bytes([1] * 100))

        self.assertTrue(os.path.isfile(file_path))
        self.assertEqual(pickle_load(
            self.log_printer, "corrupt_file", fallback=42), 42)
Ejemplo n.º 2
0
    def test_corrupt_cache_files(self):
        file_path = get_data_path(self.log_printer, "corrupt_file")
        with open(file_path, "wb") as f:
            f.write(bytes([1] * 100))

        self.assertTrue(os.path.isfile(file_path))
        self.assertEqual(
            pickle_load(self.log_printer, "corrupt_file", fallback=42), 42)
Ejemplo n.º 3
0
    def test_permission_error(self, makedirs):
        makedirs.side_effect = PermissionError
        self.assertEqual(get_data_path(self.log_printer, "test"), None)

        self.assertFalse(pickle_dump(self.log_printer, "test", {"answer": 42}))
Ejemplo n.º 4
0
 def test_delete_permission_error(self, mock_os):
     with open(get_data_path(self.log_printer, "coala_test"), "w"):
         mock_os.remove.side_effect = OSError("Permission error")
         self.assertTrue(
             os.path.isfile(get_data_path(self.log_printer, "coala_test")))
         self.assertFalse(delete_files(self.log_printer, ["coala_test"]))
Ejemplo n.º 5
0
 def test_delete_files(self):
     pickle_dump(self.log_printer, "coala_test", {"answer": 42})
     self.assertTrue(delete_files(self.log_printer, ["coala_test"]))
     self.assertFalse(
         os.path.isfile(get_data_path(self.log_printer, "coala_test")))
Ejemplo n.º 6
0
    def test_permission_error(self, makedirs):
        makedirs.side_effect = PermissionError
        self.assertEqual(get_data_path(self.log_printer, "test"), None)

        self.assertFalse(pickle_dump(self.log_printer, "test", {"answer": 42}))
Ejemplo n.º 7
0
 def test_delete_permission_error(self, mock_os):
     with open(get_data_path(self.log_printer, "coala_test"), "w"):
         mock_os.remove.side_effect = OSError("Permission error")
         self.assertTrue(os.path.isfile(get_data_path(
             self.log_printer, "coala_test")))
         self.assertFalse(delete_files(self.log_printer, ["coala_test"]))
Ejemplo n.º 8
0
 def test_delete_files(self):
     pickle_dump(self.log_printer, "coala_test", {"answer": 42})
     self.assertTrue(delete_files(
         self.log_printer, ["coala_test"]))
     self.assertFalse(os.path.isfile(get_data_path(
         self.log_printer, "coala_test")))
Ejemplo n.º 9
0
 def test_delete_permission_error(self, mock_os):
     with open(get_data_path(self.log_printer, 'coala_test'), 'w'):
         mock_os.remove.side_effect = OSError('Permission error')
         self.assertTrue(os.path.isfile(get_data_path(
             self.log_printer, 'coala_test')))
         self.assertFalse(delete_files(self.log_printer, ['coala_test']))
Ejemplo n.º 10
0
 def test_delete_files(self):
     pickle_dump(self.log_printer, 'coala_test', {'answer': 42})
     self.assertTrue(delete_files(
         self.log_printer, ['coala_test']))
     self.assertFalse(os.path.isfile(get_data_path(
         self.log_printer, 'coala_test')))
Ejemplo n.º 11
0
 def test_delete_permission_error(self, mock_os):
     with open(get_data_path(self.log_printer, 'coala_test'), 'w'):
         mock_os.remove.side_effect = OSError('Permission error')
         self.assertTrue(
             os.path.isfile(get_data_path(self.log_printer, 'coala_test')))
         self.assertFalse(delete_files(self.log_printer, ['coala_test']))
Ejemplo n.º 12
0
 def test_delete_files(self):
     pickle_dump(self.log_printer, 'coala_test', {'answer': 42})
     self.assertTrue(delete_files(self.log_printer, ['coala_test']))
     self.assertFalse(
         os.path.isfile(get_data_path(self.log_printer, 'coala_test')))