synology_link_manipultor/tests/test_helper.py

30 lines
810 B
Python

import pytest
from pathlib import Path
import os
import pandas as pd
import shutil
@pytest.fixture
def cleanup():
dir_delete = [Path('./tests/file/'), Path('./tests/target/')]
for d in dir_delete:
shutil.rmtree(str(d), ignore_errors=True)
@pytest.fixture
def create_test_files(cleanup) -> pd.DataFrame:
df = pd.DataFrame(columns=['path','target'])
Path('./tests/file/').mkdir(parents=True, exist_ok=False)
Path('./tests/target/').mkdir(parents=True, exist_ok=False)
for x in range(1,6):
p = Path('./tests/file/file' + str(x) + '.txt')
t = Path('./tests/target/target' + str(x) + '.txt')
t.touch(exist_ok=False)
p.symlink_to(t,target_is_directory=False)
df.append({'path': p, 'target': t} , ignore_index=True)
return df