Update Test Cases 0003 to 0016

* Update Test Cases 0003 to 0016
This commit is contained in:
abraunegg 2026-03-13 17:32:35 +11:00
commit 4ceec373e9
16 changed files with 69 additions and 62 deletions

View file

@ -49,6 +49,7 @@ def run_command(
command: list[str],
cwd: Path | None = None,
env: dict[str, str] | None = None,
input_text: str | None = None,
) -> CommandResult:
merged_env = os.environ.copy()
if env:
@ -64,6 +65,7 @@ def run_command(
encoding="utf-8",
errors="replace",
check=False,
input=input_text,
)
return CommandResult(

View file

@ -21,8 +21,8 @@ class TestCase0003DryRunValidation(Wave1TestCaseBase):
self._create_binary_file(seed_root / root_name / "Data" / "payload.bin", 64 * 1024)
seed_config_dir = self._new_config_dir(context, case_work_dir, "seed")
config_path, sync_list_path = self._write_config(seed_config_dir, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(seed_config_dir)
artifacts.append(str(config_path))
seed_result = self._run_onedrive(context, sync_root=seed_root, config_dir=seed_config_dir)
artifacts.extend(self._write_command_artifacts(result=seed_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="seed"))
artifacts.extend(self._write_manifests(seed_root, case_state_dir, "seed_local"))
@ -37,8 +37,8 @@ class TestCase0003DryRunValidation(Wave1TestCaseBase):
artifacts.append(self._write_json_artifact(case_state_dir / "pre_snapshot.json", pre_snapshot))
dry_config_dir = self._new_config_dir(context, case_work_dir, "dryrun")
config_path, sync_list_path = self._write_config(dry_config_dir, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(dry_config_dir)
artifacts.append(str(config_path))
dry_result = self._run_onedrive(context, sync_root=dry_root, config_dir=dry_config_dir, extra_args=["--dry-run"])
artifacts.extend(self._write_command_artifacts(result=dry_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="dry_run"))
post_snapshot = self._snapshot_files(dry_root)

View file

@ -21,8 +21,8 @@ class TestCase0004SingleDirectorySync(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "Unscoped" / "exclude.txt", "should stay local only\n")
config_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(config_dir, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(config_dir)
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=config_dir, extra_args=["--single-directory", f"{root_name}/Scoped"])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="single_directory"))
artifacts.extend(self._write_manifests(sync_root, case_state_dir, "local_after"))

View file

@ -18,8 +18,8 @@ class TestCase0005ForceSyncOverride(Wave1TestCaseBase):
seed_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(seed_root / root_name / "Blocked" / "blocked.txt", "blocked remote file\n")
seed_conf = self._new_config_dir(context, case_work_dir, "seed")
config_path, sync_list_path = self._write_config(seed_conf, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(seed_conf)
artifacts.append(str(config_path))
seed_result = self._run_onedrive(context, sync_root=seed_root, config_dir=seed_conf)
artifacts.extend(self._write_command_artifacts(result=seed_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="seed"))
if seed_result.returncode != 0:
@ -28,8 +28,8 @@ class TestCase0005ForceSyncOverride(Wave1TestCaseBase):
no_force_root = case_work_dir / "no-force-syncroot"
no_force_root.mkdir(parents=True, exist_ok=True)
no_force_conf = self._new_config_dir(context, case_work_dir, "no-force")
config_path, sync_list_path = self._write_config(no_force_conf, extra_lines=['skip_dir = "Blocked"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(no_force_conf, extra_lines=['skip_dir = "Blocked"'])
artifacts.append(str(config_path))
no_force_result = self._run_onedrive(context, sync_root=no_force_root, config_dir=no_force_conf, extra_args=["--download-only", "--single-directory", f"{root_name}/Blocked"])
artifacts.extend(self._write_command_artifacts(result=no_force_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="no_force"))
if no_force_result.returncode != 0:
@ -40,9 +40,15 @@ class TestCase0005ForceSyncOverride(Wave1TestCaseBase):
force_root = case_work_dir / "force-syncroot"
force_root.mkdir(parents=True, exist_ok=True)
force_conf = self._new_config_dir(context, case_work_dir, "force")
config_path, sync_list_path = self._write_config(force_conf, extra_lines=['skip_dir = "Blocked"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
force_result = self._run_onedrive(context, sync_root=force_root, config_dir=force_conf, extra_args=["--download-only", "--single-directory", f"{root_name}/Blocked", "--force-sync"])
config_path = self._write_config(force_conf, extra_lines=['skip_dir = "Blocked"'])
artifacts.append(str(config_path))
force_result = self._run_onedrive(
context,
sync_root=force_root,
config_dir=force_conf,
extra_args=["--download-only", "--single-directory", f"{root_name}/Blocked", "--force-sync"],
input_text="Y\n",
)
artifacts.extend(self._write_command_artifacts(result=force_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="force"))
artifacts.extend(self._write_manifests(force_root, case_state_dir, "force_manifest"))
if force_result.returncode != 0:

View file

@ -17,8 +17,8 @@ class TestCase0006DownloadOnly(Wave1TestCaseBase):
seed_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(seed_root / root_name / "Remote" / "download_me.txt", "remote file\n")
seed_conf = self._new_config_dir(context, case_work_dir, "seed")
config_path, sync_list_path = self._write_config(seed_conf, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(seed_conf)
artifacts.append(str(config_path))
seed_result = self._run_onedrive(context, sync_root=seed_root, config_dir=seed_conf)
artifacts.extend(self._write_command_artifacts(result=seed_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="seed"))
if seed_result.returncode != 0:
@ -28,8 +28,8 @@ class TestCase0006DownloadOnly(Wave1TestCaseBase):
sync_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(sync_root / root_name / "LocalOnly" / "stay_local.txt", "must not upload\n")
conf_dir = self._new_config_dir(context, case_work_dir, "download")
config_path, sync_list_path = self._write_config(conf_dir, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir)
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--download-only"])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="download_only"))
artifacts.extend(self._write_manifests(sync_root, case_state_dir, "local_after"))

View file

@ -17,8 +17,8 @@ class TestCase0007DownloadOnlyCleanupLocalFiles(Wave1TestCaseBase):
seed_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(seed_root / root_name / "Keep" / "keep.txt", "keep\n")
seed_conf = self._new_config_dir(context, case_work_dir, "seed")
config_path, sync_list_path = self._write_config(seed_conf, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(seed_conf)
artifacts.append(str(config_path))
seed_result = self._run_onedrive(context, sync_root=seed_root, config_dir=seed_conf)
artifacts.extend(self._write_command_artifacts(result=seed_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="seed"))
if seed_result.returncode != 0:
@ -29,9 +29,14 @@ class TestCase0007DownloadOnlyCleanupLocalFiles(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "Keep" / "keep.txt", "local keep placeholder\n")
self._create_text_file(sync_root / root_name / "Obsolete" / "old.txt", "obsolete\n")
conf_dir = self._new_config_dir(context, case_work_dir, "cleanup")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['cleanup_local_files = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--download-only"])
config_path = self._write_config(conf_dir, extra_lines=['cleanup_local_files = "true"'])
artifacts.append(str(config_path))
result = self._run_onedrive(
context,
sync_root=sync_root,
config_dir=conf_dir,
extra_args=["--download-only", "--single-directory", root_name],
)
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="cleanup_download_only"))
artifacts.extend(self._write_manifests(sync_root, case_state_dir, "local_after"))
if result.returncode != 0:

View file

@ -18,8 +18,8 @@ class TestCase0008UploadOnly(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "Upload" / "file.txt", "upload me\n")
self._create_binary_file(sync_root / root_name / "Upload" / "blob.bin", 70 * 1024)
conf_dir = self._new_config_dir(context, case_work_dir, "upload")
config_path, sync_list_path = self._write_config(conf_dir, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir)
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--upload-only"])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="upload_only"))
if result.returncode != 0:

View file

@ -17,8 +17,8 @@ class TestCase0009UploadOnlyNoRemoteDelete(Wave1TestCaseBase):
seed_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(seed_root / root_name / "RemoteKeep" / "preserve.txt", "preserve remotely\n")
seed_conf = self._new_config_dir(context, case_work_dir, "seed")
config_path, sync_list_path = self._write_config(seed_conf, sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(seed_conf)
artifacts.append(str(config_path))
seed_result = self._run_onedrive(context, sync_root=seed_root, config_dir=seed_conf)
artifacts.extend(self._write_command_artifacts(result=seed_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="seed"))
if seed_result.returncode != 0:
@ -28,8 +28,8 @@ class TestCase0009UploadOnlyNoRemoteDelete(Wave1TestCaseBase):
sync_root.mkdir(parents=True, exist_ok=True)
self._create_text_file(sync_root / root_name / "LocalUpload" / "new.txt", "new upload\n")
conf_dir = self._new_config_dir(context, case_work_dir, "upload")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['no_remote_delete = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir, extra_lines=['no_remote_delete = "true"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--upload-only"])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="upload_only_no_remote_delete"))
if result.returncode != 0:

View file

@ -18,8 +18,8 @@ class TestCase0010UploadOnlyRemoveSourceFiles(Wave1TestCaseBase):
source_file = sync_root / root_name / "Source" / "upload_and_remove.txt"
self._create_text_file(source_file, "remove after upload\n")
conf_dir = self._new_config_dir(context, case_work_dir, "upload")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['remove_source_files = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir, extra_lines=['remove_source_files = "true"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--upload-only"])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="upload_only_remove_source"))
artifacts.extend(self._write_manifests(sync_root, case_state_dir, "local_after"))

View file

@ -20,8 +20,8 @@ class TestCase0011SkipFileValidation(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "editor.swp", "swap\n")
self._create_text_file(sync_root / root_name / "Nested" / "keep.md", "nested keep\n")
conf_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['skip_file = "*.tmp|*.swp"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir, extra_lines=['skip_file = "*.tmp|*.swp"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir)
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="skip_file"))
if result.returncode != 0:

View file

@ -21,8 +21,8 @@ class TestCase0012SkipDirValidation(Wave1TestCaseBase):
self._create_text_file(loose_root / root_name / "build" / "root.bin", "skip me too\n")
self._create_text_file(loose_root / root_name / "project" / "src" / "app.txt", "keep me\n")
loose_conf = self._new_config_dir(context, case_work_dir, "loose")
config_path, sync_list_path = self._write_config(loose_conf, extra_lines=['skip_dir = "build"', 'skip_dir_strict_match = "false"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(loose_conf, extra_lines=['skip_dir = "build"', 'skip_dir_strict_match = "false"'])
artifacts.append(str(config_path))
loose_result = self._run_onedrive(context, sync_root=loose_root, config_dir=loose_conf)
artifacts.extend(self._write_command_artifacts(result=loose_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="loose_match"))
if loose_result.returncode != 0:
@ -46,8 +46,8 @@ class TestCase0012SkipDirValidation(Wave1TestCaseBase):
self._create_text_file(strict_root / strict_scope / "other" / "build" / "keep.bin", "keep strict\n")
self._create_text_file(strict_root / strict_scope / "other" / "src" / "keep.txt", "keep strict txt\n")
strict_conf = self._new_config_dir(context, case_work_dir, "strict")
config_path, sync_list_path = self._write_config(strict_conf, extra_lines=[f'skip_dir = "{strict_scope}/project/build"', 'skip_dir_strict_match = "true"'], sync_list_entries=[f"/{strict_scope}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(strict_conf, extra_lines=[f'skip_dir = "{strict_scope}/project/build"', 'skip_dir_strict_match = "true"'])
artifacts.append(str(config_path))
strict_result = self._run_onedrive(context, sync_root=strict_root, config_dir=strict_conf)
artifacts.extend(self._write_command_artifacts(result=strict_result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="strict_match"))
if strict_result.returncode != 0:

View file

@ -20,9 +20,9 @@ class TestCase0013SkipDotfilesValidation(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "visible.txt", "visible\n")
self._create_text_file(sync_root / root_name / "normal" / "keep.md", "normal keep\n")
conf_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['skip_dotfiles = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir)
config_path = self._write_config(conf_dir, extra_lines=['skip_dotfiles = "true"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--single-directory", root_name])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="skip_dotfiles"))
if result.returncode != 0:
return TestResult.fail_result(self.case_id, self.name, f"skip_dotfiles validation failed with status {result.returncode}", artifacts)

View file

@ -18,9 +18,9 @@ class TestCase0014SkipSizeValidation(Wave1TestCaseBase):
self._create_binary_file(sync_root / root_name / "small.bin", 128 * 1024)
self._create_binary_file(sync_root / root_name / "large.bin", 2 * 1024 * 1024)
conf_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['skip_size = "1"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir)
config_path = self._write_config(conf_dir, extra_lines=['skip_size = "1"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir, extra_args=["--single-directory", root_name])
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="skip_size"))
if result.returncode != 0:
return TestResult.fail_result(self.case_id, self.name, f"skip_size validation failed with status {result.returncode}", artifacts)

View file

@ -23,8 +23,8 @@ class TestCase0015SkipSymlinksValidation(Wave1TestCaseBase):
symlink_path.parent.mkdir(parents=True, exist_ok=True)
os.symlink("real.txt", symlink_path)
conf_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['skip_symlinks = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir, extra_lines=['skip_symlinks = "true"'])
artifacts.append(str(config_path))
artifacts.append(self._write_json_artifact(case_state_dir / "local_snapshot_pre.json", self._snapshot_files(sync_root)))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir)
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="skip_symlinks"))

View file

@ -19,8 +19,8 @@ class TestCase0016CheckNosyncValidation(Wave1TestCaseBase):
self._create_text_file(sync_root / root_name / "Blocked" / "blocked.txt", "blocked\n")
self._create_text_file(sync_root / root_name / "Allowed" / "allowed.txt", "allowed\n")
conf_dir = self._new_config_dir(context, case_work_dir, "main")
config_path, sync_list_path = self._write_config(conf_dir, extra_lines=['check_nosync = "true"'], sync_list_entries=[f"/{root_name}"])
artifacts.extend([str(config_path), str(sync_list_path)])
config_path = self._write_config(conf_dir, extra_lines=['check_nosync = "true"'])
artifacts.append(str(config_path))
result = self._run_onedrive(context, sync_root=sync_root, config_dir=conf_dir)
artifacts.extend(self._write_command_artifacts(result=result, log_dir=case_log_dir, state_dir=case_state_dir, phase_name="check_nosync"))
if result.returncode != 0:

View file

@ -18,12 +18,14 @@ from framework.utils import (
)
CONFIG_FILE_NAME = "config"
SYNC_LIST_FILE_NAME = "sync_list"
class Wave1TestCaseBase(E2ETestCase):
"""
Shared helper base for Wave 1 E2E test cases.
Important design rule: Wave 1 test cases must not use sync_list.
TC0002 is the sole owner of sync_list validation.
"""
def _safe_run_id(self, context: E2EContext) -> str:
@ -53,25 +55,19 @@ class Wave1TestCaseBase(E2ETestCase):
config_dir: Path,
*,
extra_lines: Iterable[str] | None = None,
sync_list_entries: Iterable[str] | None = None,
) -> tuple[Path, Path | None]:
) -> Path:
config_path = config_dir / CONFIG_FILE_NAME
sync_list_path: Path | None = None
lines = [
f"# tc{self.case_id} generated config",
'bypass_data_preservation = "true"',
'monitor_interval = "5"',
'monitor_interval = 5',
]
if extra_lines:
lines.extend(list(extra_lines))
write_text_file(config_path, "\n".join(lines) + "\n")
if sync_list_entries is not None:
sync_list_path = config_dir / SYNC_LIST_FILE_NAME
write_text_file(sync_list_path, "\n".join(sync_list_entries) + "\n")
return config_path, sync_list_path
return config_path
def _run_onedrive(
self,
@ -82,6 +78,7 @@ class Wave1TestCaseBase(E2ETestCase):
extra_args: list[str] | None = None,
use_resync: bool = True,
use_resync_auth: bool = True,
input_text: str | None = None,
):
command = [context.onedrive_bin, "--sync", "--verbose"]
if use_resync:
@ -93,7 +90,7 @@ class Wave1TestCaseBase(E2ETestCase):
command.extend(extra_args)
context.log(f"Executing Test Case {self.case_id}: {command_to_string(command)}")
return run_command(command, cwd=context.repo_root)
return run_command(command, cwd=context.repo_root, input_text=input_text)
def _write_command_artifacts(
self,
@ -183,18 +180,15 @@ class Wave1TestCaseBase(E2ETestCase):
verify_root = case_work_dir / f"verify-{name}"
reset_directory(verify_root)
config_dir = self._new_config_dir(context, case_work_dir, f"verify-{name}")
config_path, sync_list_path = self._write_config(
config_path = self._write_config(
config_dir,
extra_lines=extra_config_lines,
sync_list_entries=[f"/{scope_root}"],
)
result = self._run_onedrive(
context,
sync_root=verify_root,
config_dir=config_dir,
extra_args=["--download-only"] + (extra_args or []),
extra_args=["--download-only", "--single-directory", scope_root] + (extra_args or []),
)
artifacts = [str(config_path)]
if sync_list_path:
artifacts.append(str(sync_list_path))
return verify_root, result, artifacts