Browse Source

Added script to fill mock_backup_data

master
Raphael Roberts 5 years ago
parent
commit
219817a7e7
  1. 31
      test_data/mock_backup_data/mock_backupdir.py
  2. 15
      tests/fixtures/mock_backupdir.py

31
test_data/mock_backup_data/mock_backupdir.py

@ -0,0 +1,31 @@
#!/usr/bin/env python
from argparse import ArgumentParser
from pathlib import Path
import shutil
def fill_mock_backup_dir(rootdir: Path, target_dir: Path, verbose=False):
if (target_dir / "marker").exists():
return
for property_file in rootdir.glob("*.properties"):
if verbose:
print(f"Property file: {property_file}")
shutil.copy2(property_file, target_dir / property_file.name)
for other_file in filter(
lambda path: path.suffix != ".properties", rootdir.glob("*")
):
print(f"Data/apk file: {other_file}")
dest = target_dir / other_file.name
dest.touch(exist_ok=True)
(target_dir / "marker").touch()
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument("backup_dir", type=Path)
parser.add_argument("mock_dir", default=".", type=Path, nargs="?")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
fill_mock_backup_dir(args.backup_dir, args.mock_dir, args.verbose)

15
tests/fixtures/mock_backupdir.py

@ -1,15 +0,0 @@
import pytest
import shutil
from pathlib import Path
def fill_mock_backup_dir(rootdir: Path, target_dir: Path):
for property_file in rootdir.glob("*.properties"):
shutil.copy2(property_file, target_dir / property_file.name)
for other_file in filter(
lambda path: path.suffix != ".properties", rootdir.glob("*")
):
dest = target_dir / other_file.name
dest.touch(exist_ok=True)
Loading…
Cancel
Save