def test_file_order_does_not_matter(self): files = ['file', 'file2'] file_finder = lambda: files get_file_size = lambda x: 1 get_file_modification_time = lambda x: 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) files[:] = ['file2', 'file'] change_detected = monitor.look_for_changes() assert not change_detected
def test_nothing_changed(self): def file_finder(): return ['file'] def get_file_size(file): return 1 def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) change_detected = monitor.look_for_changes() assert not change_detected
def test_file_size_changed(self): files = ['file'] filesize = [1] file_finder = lambda: files get_file_size = lambda x: filesize[0] get_file_modification_time = lambda x: 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) filesize[0] = 5 change_detected = monitor.look_for_changes() assert change_detected
def test_file_order_does_not_matter(self): files = ['file', 'file2'] def file_finder(): return files def get_file_size(file): return 1 def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) files[:] = ['file2', 'file'] change_detected = monitor.look_for_changes() assert not change_detected
def dtest_modification_time_changed(self): def file_finder(): return ['file'] def get_file_size(file): return 1 modtime = [1] def get_file_modification_time(file): return modtime[0] monitor = Monitor(file_finder, get_file_size, get_file_modification_time) modtime[0] = 2 change_detected = monitor.look_for_changes() assert change_detected
def test_renaming_file(self): files = ['file'] def file_finder(): return files def get_file_size(file): return 1 def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) files[0] = 'renamed' change_detected = monitor.look_for_changes() assert change_detected
def test_adding_file(self): files = ['file'] def file_finder(): return files def get_file_size(file): return 1 def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) files.append('file2') change_detected = monitor.look_for_changes() assert change_detected
def test_file_size_changed(self): files = ['file'] filesize = [1] def file_finder(): return files def get_file_size(file): return filesize[0] def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) filesize[0] = 5 change_detected = monitor.look_for_changes() assert change_detected
def test_change_is_only_detected_once(self): files = ['file'] def file_finder(): return files def get_file_size(file): return 1 def get_file_modification_time(file): return 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) files[0] = 'changed' change_detected = monitor.look_for_changes() change_detected = monitor.look_for_changes() assert not change_detected
def _set_up_monitor(self): files = ['file'] file_finder = lambda: files get_file_size = lambda x: 1 get_file_modification_time = lambda x: 1 monitor = Monitor(file_finder, get_file_size, get_file_modification_time) return files, monitor
def _set_up_monitor(self): self.t_files = ['file'] self.t_fsize = 1 self.t_modtime = 1 file_finder = lambda: self.t_files get_file_size = lambda x: self.t_fsize get_file_modification_time = lambda x: self.t_modtime monitor = Monitor(file_finder, get_file_size, get_file_modification_time) return monitor