def test_min(): now = pendulum.now() last_modified = LastModified(days=10, hours=12, mode="older") with patch.object(last_modified, "_last_modified") as mock_lm: mock_lm.return_value = now - pendulum.duration(days=10, hours=0) assert not last_modified.run(path=Path("~")) mock_lm.return_value = now - pendulum.duration(days=10, hours=13) assert last_modified.run(path=Path("~"))
def test_min(): now = datetime.now() last_modified = LastModified(days=10, hours=12, mode='older') with patch.object(last_modified, '_last_modified') as mock_lm: mock_lm.return_value = now - timedelta(days=10, hours=0) assert not last_modified.matches(Path('~')) mock_lm.return_value = now - timedelta(days=10, hours=13) assert last_modified.matches(Path('~'))
def test_min(): now = datetime.now() last_modified = LastModified(days=10, hours=12, mode="older") with patch.object(last_modified, "_last_modified") as mock_lm: mock_lm.return_value = now - timedelta(days=10, hours=0) assert not last_modified.run(path=Path("~")) mock_lm.return_value = now - timedelta(days=10, hours=13) assert last_modified.run(path=Path("~"))
def test_yaml_ref(): config = """ media: &media - wav - png all_folders: &all - ~/Desktop - ~/Documents rules: - folders: *all filters: - Extension: *media - Extension: - *media - jpg - LastModified: days: 10 actions: - Echo: msg: 'Hello World' - folders: - *all - /more/more filters: actions: - Trash """ conf = Config.from_string(config) assert conf.rules == [ Rule( folders=['~/Desktop', '~/Documents'], filters=[ Extension('.wav', '.PNG'), Extension('.wav', '.PNG', 'jpg'), LastModified(days=10) ], actions=[Echo(msg='Hello World')], subfolders=False, system_files=False, ), Rule( folders=['~/Desktop', '~/Documents', '/more/more'], filters=[], actions=[Trash()], subfolders=False, system_files=False, ) ]
def test_yaml_ref(): config = """ media: &media - wav - png all_folders: &all - ~/Desktop - ~/Documents rules: - folders: *all filters: - extension: *media - extension: - *media - jpg - lastmodified: days: 10 actions: - echo: msg: 'Hello World' - folders: - *all - /more/more filters: actions: - trash """ conf = Config.from_string(config) assert conf.rules == [ Rule( folders=["~/Desktop", "~/Documents"], filters=[ Extension(".wav", ".PNG"), Extension(".wav", ".PNG", "jpg"), LastModified(days=10), ], actions=[Echo(msg="Hello World")], subfolders=False, system_files=False, ), Rule( folders=["~/Desktop", "~/Documents", "/more/more"], filters=[], actions=[Trash()], subfolders=False, system_files=False, ), ]