-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: resolve relative datasample spec path (#392)
Signed-off-by: ThibaultFy <50656860+ThibaultFy@users.noreply.github.com>
- Loading branch information
1 parent
872d484
commit 9ba1cf9
Showing
4 changed files
with
68 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pathlib | ||
import uuid | ||
|
||
import pytest | ||
|
||
from substra.sdk.schemas import DataSampleSpec | ||
|
||
|
||
@pytest.mark.parametrize("path", [pathlib.Path() / "data", "./data", pathlib.Path().cwd() / "data"]) | ||
def test_datasample_spec_resolve_path(path): | ||
datasample_spec = DataSampleSpec(path=path, data_manager_keys=[str(uuid.uuid4())]) | ||
|
||
assert datasample_spec.path == pathlib.Path().cwd() / "data" | ||
|
||
|
||
def test_datasample_spec_resolve_paths(): | ||
paths = [pathlib.Path() / "data", "./data", pathlib.Path().cwd() / "data"] | ||
datasample_spec = DataSampleSpec(paths=paths, data_manager_keys=[str(uuid.uuid4())]) | ||
|
||
assert all([path == pathlib.Path().cwd() / "data" for path in datasample_spec.paths]) | ||
|
||
|
||
def test_datasample_spec_exclusive_path(): | ||
with pytest.raises(ValueError): | ||
DataSampleSpec(paths=["fake_paths"], path="fake_paths", data_manager_keys=[str(uuid.uuid4())]) | ||
|
||
|
||
def test_datasample_spec_no_path(): | ||
with pytest.raises(ValueError): | ||
DataSampleSpec(data_manager_keys=[str(uuid.uuid4())]) |