def test_perform_actions_copy_on_file(example_migration_sheet, fs): _mock_directory_structure(fs) fs.create_file('/target-directory/c/e/data') actions = sheet_to_actions(example_migration_sheet) with pytest.raises(IOError): perform_actions(actions)
def test_perform_actions(example_migration_sheet, fs, caplog): _mock_directory_structure(fs) actions = sheet_to_actions(example_migration_sheet) with caplog.at_level(logging.WARNING): perform_actions(actions) # check if logged on missing actions warnings = [r for r in caplog.records if r.levelname == 'WARNING'] assert len(warnings) == 2 # check if ignored assert os.path.exists('/source-directory/a') assert not os.path.exists('/target-directory/c/d/ignore') assert not os.path.exists('/target-directory/c/e/ignore') # check if deleted assert not os.path.exists('/source-directory/c/d/results/Thumbs.db') assert not os.path.exists('/target-directory/c/d/results/Thumbs.db') # check if moved assert os.path.exists('/target-directory/c/d') assert os.path.exists('/target-directory/c/d/results') assert os.path.exists('/target-directory/c/d/scripts/example.py') # check if copied assert os.path.exists('/target-directory/c/e') assert os.path.exists('/target-directory/c/e/data')
def test_perform_actions_missing_source(example_migration_sheet, fs): fs.create_dir('/source-directory/a/b') fs.create_file('/source-directory/c/d/Pipfile') fs.create_file('/source-directory/c/d/results/Thumbs.db') fs.create_file('/source-directory/c/d/scripts/example.py') actions = sheet_to_actions(example_migration_sheet) with pytest.raises(IOError): perform_actions(actions)
def test_dry_run_actions(example_migration_sheet, fs, caplog): _mock_source_directory_structure(fs) actions = sheet_to_actions(example_migration_sheet) with caplog.at_level(logging.INFO): dry_run_actions(actions) assert not os.path.exists('/target-directory') assert os.path.exists('/source-directory/a')
def test_sheet_to_actions(example_migration_sheet): actions = sheet_to_actions(example_migration_sheet) assert isinstance(actions, dict) assert len(actions) == 6