-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into fix/dataset_assets_contributor_uploader
- Loading branch information
Showing
4 changed files
with
79 additions
and
6 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 |
---|---|---|
|
@@ -9,11 +9,14 @@ | |
import pytest | ||
|
||
# syft absolute | ||
import syft as sy | ||
from syft.node.worker import Worker | ||
from syft.service.action.action_object import ActionObject | ||
from syft.service.dataset.dataset import CreateAsset as Asset | ||
from syft.service.dataset.dataset import CreateDataset as Dataset | ||
from syft.service.dataset.dataset import _ASSET_WITH_NONE_MOCK_ERROR_MESSAGE | ||
from syft.service.response import SyftError | ||
from syft.service.response import SyftSuccess | ||
from syft.types.twin_object import TwinMode | ||
|
||
|
||
|
@@ -216,3 +219,35 @@ def test_domain_client_cannot_upload_dataset_with_non_mock(worker: Worker) -> No | |
root_domain_client.upload_dataset(dataset) | ||
|
||
assert _ASSET_WITH_NONE_MOCK_ERROR_MESSAGE in str(excinfo.value) | ||
|
||
|
||
def test_adding_contributors_with_duplicate_email(): | ||
# Datasets | ||
|
||
dataset = Dataset(name="Sample dataset") | ||
res1 = dataset.add_contributor( | ||
role=sy.roles.UPLOADER, name="Alice", email="[email protected]" | ||
) | ||
res2 = dataset.add_contributor( | ||
role=sy.roles.UPLOADER, name="Alice Smith", email="[email protected]" | ||
) | ||
|
||
assert isinstance(res1, SyftSuccess) | ||
assert isinstance(res2, SyftError) | ||
assert len(dataset.contributors) == 1 | ||
|
||
# Assets | ||
asset = Asset(**make_asset_without_mock(), mock=ActionObject.empty()) | ||
|
||
res3 = asset.add_contributor( | ||
role=sy.roles.UPLOADER, name="Bob", email="[email protected]" | ||
) | ||
|
||
res4 = asset.add_contributor( | ||
role=sy.roles.UPLOADER, name="Bob Abraham", email="[email protected]" | ||
) | ||
dataset.add_asset(asset) | ||
|
||
assert isinstance(res3, SyftSuccess) | ||
assert isinstance(res4, SyftError) | ||
assert len(asset.contributors) == 1 |