-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: curator API fix tests #3782
Changes from 39 commits
d8ae6f2
8f5cccc
f75c82c
63d18bf
a0d83d6
7e9cb8c
d7bf076
5d02dcb
2d94fb5
9e0a2cb
fcc66bb
0a8e04e
541dbb0
e90f561
51eac97
8bf68ce
00fd5f1
a05e666
f798571
e67750c
8151e66
418cc68
d1b5c45
a26b427
99163ea
a18c455
af4f001
000655a
8b7078a
1696ca9
34047f0
457a216
633a52d
e381d8f
a0037f4
ba5daa0
71dbf18
200f249
e131d03
b97c5c5
ea188a6
0e4f484
0984314
0b2fc2e
f6a04b4
35b2647
76a8e52
f9a3115
d8866ce
a24de08
40a9766
9747f6c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,9 +68,7 @@ def create_canonical_collection( | |
) -> CollectionVersion: | ||
collection_id = CollectionId(self._generate_id()) | ||
version_id = CollectionVersionId(self._generate_id()) | ||
canonical = CanonicalCollection( | ||
id=collection_id, version_id=version_id, originally_published_at=None, tombstoned=False | ||
) | ||
canonical = CanonicalCollection(collection_id, None, None, False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why don't we set the version_id here? Do we only add the version_id if the version is published? If this is the case then if a collection is not published, what happens if the user goes to the collection page using the canonical collection id? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the canonical -> version mapping only needs to exist for published collections. A canonical collection can have multiple versions, but only one can be actively published at the same time - hence this mapping. @atolopko-czi has a diagram that might explain this better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if the user goes to an unpublished collection page using the canonical collection id? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a use case where a user would like to use the canonical id before it is published so they can reference it in their publications. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will add a ticket to make sure this behavior is supported. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
version = CollectionVersion( | ||
collection_id=collection_id, | ||
version_id=version_id, | ||
|
@@ -84,7 +82,6 @@ def create_canonical_collection( | |
datasets=[], | ||
) | ||
self.collections_versions[version_id.id] = version | ||
self.collections[collection_id.id] = canonical | ||
# Don't set mappings here - those will be set when publishing the collection! | ||
return copy.deepcopy(version) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
from backend.portal.api.curation.v1.curation.collections.common import EntityColumns | ||
from tests.unit.backend.fixtures.mock_aws_test_case import CorporaTestCaseUsingMockAWS | ||
from tests.unit.backend.layers.common.base_test import DatasetArtifactUpdate, DatasetStatusUpdate | ||
from unit.backend.layers.common.base_api_test import BaseAPIPortalTest | ||
from tests.unit.backend.layers.common.base_api_test import BaseAPIPortalTest | ||
|
||
|
||
class TestAsset(CorporaTestCaseUsingMockAWS): | ||
|
@@ -138,8 +138,18 @@ def test__delete_tombstone_collection(self): | |
|
||
|
||
class TestS3Credentials(BaseAPIPortalTest): | ||
@patch("backend.common.corpora_config.CorporaConfig.__getattr__") | ||
@patch("backend.portal.api.curation.v1.curation.collections.collection_id.s3_upload_credentials.sts_client") | ||
def test__generate_s3_credentials__OK(self, sts_client: Mock): | ||
def test__generate_s3_credentials__OK(self, sts_client: Mock, mock_config: Mock): | ||
|
||
def mock_config_fn(name): | ||
if name == "curator_role_arn": | ||
return "test_role_arn" | ||
if name == "submission_bucket": | ||
return "cellxgene-dataset-submissions-test" | ||
|
||
mock_config.side_effect = mock_config_fn | ||
|
||
def _test(token, is_super_curator: bool = False): | ||
sts_client.assume_role_with_web_identity = Mock( | ||
return_value={ | ||
|
@@ -150,17 +160,17 @@ def _test(token, is_super_curator: bool = False): | |
} | ||
} | ||
) | ||
collection_id = self.generate_unpublished_collection().collection_id | ||
version_id = self.generate_unpublished_collection().version_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to test with both the version_id and collection_id There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should now work with both, I'll add the double tests. |
||
headers = {"Authorization": f"Bearer {token}"} | ||
|
||
response = self.app.get(f"/curation/v1/collections/{collection_id}/s3-upload-credentials", headers=headers) | ||
response = self.app.get(f"/curation/v1/collections/{version_id}/s3-upload-credentials", headers=headers) | ||
self.assertEqual(200, response.status_code) | ||
token_sub = self._mock_assert_authorized_token(token)["sub"] | ||
self.assertEqual(response.json["Bucket"], "cellxgene-dataset-submissions-test") | ||
if is_super_curator: | ||
self.assertEqual(response.json["UploadKeyPrefix"], f"super/{collection_id}/") | ||
self.assertEqual(response.json["UploadKeyPrefix"], f"super/{version_id}/") | ||
else: | ||
self.assertEqual(response.json["UploadKeyPrefix"], f"{token_sub}/{collection_id}/") | ||
self.assertEqual(response.json["UploadKeyPrefix"], f"{token_sub}/{version_id}/") | ||
|
||
with self.subTest("collection owner"): | ||
_test("owner") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -149,7 +149,7 @@ def test__get_collection_id__ok(self): | |
"contact_email": "[email protected]", | ||
"contact_name": "john doe", | ||
"created_at": mock.ANY, | ||
"curator_name": "Test User", | ||
"curator_name": "Jane Smith", | ||
"data_submission_policy_version": "1.0", | ||
"datasets": [ | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pydantic.dataclass should work as long as we aren't mixing class members with and without defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's work on pydantic on a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then remove these imports