def test_converts_workflow_app_to_bidsapp(self, fake_snakemake: Path): with (fake_snakemake / "output" / ".snakebids").open("w") as f: json.dump({"mode": "bidsapp"}, f) output.prepare_output(fake_snakemake / "app1", fake_snakemake / "output", "workflow", False) assert not (fake_snakemake / "output" / ".snakemake").exists() (fake_snakemake / "output" / ".snakemake").touch() out = output.prepare_output(fake_snakemake / "app1", fake_snakemake / "output", "bidsapp", True) assert out == fake_snakemake / "output" assert (fake_snakemake / "output" / ".snakemake").exists() assert out.exists() assert dirlen(out) == 4 with (out / ".snakebids").open() as f: assert json.load(f)["mode"] == "bidsapp"
def test_creates_new_empty_bidsapp(self, fake_snakemake: Path): out = output.prepare_output(fake_snakemake / "app1", fake_snakemake / "new-output", "bidsapp", False) assert out == fake_snakemake / "new-output" assert out.exists() assert dirlen(out) == 1 with (out / ".snakebids").open() as f: assert json.load(f)["mode"] == "bidsapp"
def test_creates_new_empty_workflow_app(self, fake_snakemake: Path): out = output.prepare_output(fake_snakemake / "app1", fake_snakemake / "new-output", "workflow", False) assert out == fake_snakemake / "new-output" / "results" assert dirlen(fake_snakemake / "new-output") == 5 assert out.exists() assert dirlen(out) == 0 with (fake_snakemake / "new-output" / ".snakebids").open() as f: assert json.load(f)["mode"] == "workflow"
def test_converts_bidsapp_to_workflow(self, fake_snakemake: Path): with (fake_snakemake / "output" / ".snakebids").open("w") as f: json.dump({"mode": "bidsapp"}, f) out = output.prepare_output(fake_snakemake / "app1", fake_snakemake / "output", "workflow", False) assert out == fake_snakemake / "output" / "results" assert not (out / ".snakemake").exists() assert dirlen(fake_snakemake / "output") == 5 assert out.exists() assert dirlen(out) == 2 with (fake_snakemake / "output" / ".snakebids").open() as f: assert json.load(f)["mode"] == "workflow"
def test_fails_when_directory_has_contents(self, fake_snakemake: Path): with pytest.raises(RunError): output.prepare_output(fake_snakemake / "app1", fake_snakemake / "randomdir", "workflow", False)