Example #1
0
 def write(self):
     """
     Update the last run time on the project for each file
     to the current time. Using this object as a contextmanager is
     preferred (that will automatically call this method on exit).
     """
     for file_name in self.data:
         self.data[file_name] = self.current_time
     pickle_dump(
         self.log_printer,
         self.project_dir,
         {"time": self.current_time, "files": self.data})
Example #2
0
 def write(self):
     """
     Update the last run time on the project for each file
     to the current time. Using this object as a contextmanager is
     preferred (that will automatically call this method on exit).
     """
     for file_name in self.data:
         self.data[file_name] = self.current_time
     pickle_dump(self.log_printer, self.project_dir, {
         "time": self.current_time,
         "files": self.data
     })
Example #3
0
    def test_time_travel(self):
        cache = FileCache(self.log_printer, 'coala_test2', flush_cache=True)
        cache.track_files({'file.c'})
        cache.write()
        self.assertTrue('file.c' in cache.data)

        cache_data = pickle_load(self.log_printer, 'coala_test2', {})
        # Back to the future :)
        cache_data['time'] = 2000000000
        pickle_dump(self.log_printer, 'coala_test2', cache_data)

        cache = FileCache(self.log_printer, 'coala_test2', flush_cache=False)
        self.assertFalse('file.c' in cache.data)
Example #4
0
    def test_time_travel(self):
        cache = FileCache(self.log_printer, 'coala_test2', flush_cache=True)
        cache.track_files({'file.c'})
        cache.write()
        self.assertTrue('file.c' in cache.data)

        cache_data = pickle_load(self.log_printer, 'coala_test2', {})
        # Back to the future :)
        cache_data['time'] = 2000000000
        pickle_dump(self.log_printer, 'coala_test2', cache_data)

        cache = FileCache(self.log_printer, 'coala_test2', flush_cache=False)
        self.assertFalse('file.c' in cache.data)
Example #5
0
    def test_time_travel(self):
        cache = FileCache(self.log_printer, "coala_test2", flush_cache=True)
        cache.track_files({"file.c"})
        cache.write()
        self.assertTrue("file.c" in cache.data)

        cache_data = pickle_load(self.log_printer, "coala_test2", {})
        # Back to the future :)
        cache_data["time"] = 2000000000
        pickle_dump(self.log_printer, "coala_test2", cache_data)

        cache = FileCache(self.log_printer, "coala_test2", flush_cache=False)
        self.assertFalse("file.c" in cache.data)
Example #6
0
    def test_time_travel(self):
        cache = FileCache(self.log_printer, "coala_test2", flush_cache=True)
        cache.track_files({"file.c"})
        cache.write()
        self.assertTrue("file.c" in cache.data)

        cache_data = pickle_load(self.log_printer, "coala_test2", {})
        # Back to the future :)
        cache_data["time"] = 2000000000
        pickle_dump(self.log_printer, "coala_test2", cache_data)

        cache = FileCache(self.log_printer, "coala_test2", flush_cache=False)
        self.assertFalse("file.c" in cache.data)
Example #7
0
 def write(self):
     """
     Update the last run time on the project for each file
     to the current time. Using this object as a contextmanager is
     preferred (that will automatically call this method on exit).
     """
     for file in self.to_untrack:
         if file in self.data:
             del self.data[file]
     for file_name in self.data:
         self.data[file_name] = self.current_time
     pickle_dump(
         None,
         self.project_dir,
         {'time': self.current_time, 'files': self.data})
Example #8
0
 def write(self):
     """
     Update the last run time on the project for each file
     to the current time. Using this object as a contextmanager is
     preferred (that will automatically call this method on exit).
     """
     for file in self.to_untrack:
         if file in self.data:
             del self.data[file]
     for file_name in self.data:
         self.data[file_name] = self.current_time
     pickle_dump(None, self.project_dir, {
         'time': self.current_time,
         'files': self.data
     })
Example #9
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}))
Example #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")))
    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_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_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')))
Example #14
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')))