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)
Beispiel #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)
Beispiel #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}))
Beispiel #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"]))
Beispiel #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")))
    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}))
 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"]))
 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")))
 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']))
 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')))
Beispiel #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']))
Beispiel #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')))