This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -382,15 +382,60 @@ class TestWorkflowSearchFilterViewSet(BaseTransactionTestCase): | |
def setUp(self): | ||
super().setUp() | ||
|
||
Workflow.objects.create( | ||
data={}, | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
Workflow.objects.update_or_create( | ||
data={ | ||
"ids": [ | ||
{ | ||
"value": "0000-0003-3302-3333", | ||
"schema": "ORCID" | ||
}, | ||
{ | ||
"value": "CastleFrank", | ||
"schema": "INSPIRE BAI" | ||
} | ||
], | ||
"name": { | ||
"value": "Castle, Frank", | ||
"preferred_name": "Frank Castle" | ||
}, | ||
"email_addresses": [ | ||
{ | ||
"value": "[email protected]", | ||
"current": True | ||
} | ||
] | ||
}, | ||
status=StatusChoices.APPROVAL, | ||
core=True, | ||
is_update=False, | ||
workflow_type=WorkflowType.AUTHOR_CREATE, | ||
) | ||
Workflow.objects.create( | ||
data={}, | ||
Workflow.objects.update_or_create( | ||
data={ | ||
"ids": [ | ||
{ | ||
"value": "0000-0003-3302-2222", | ||
"schema": "ORCID" | ||
}, | ||
{ | ||
"value": "SmithJohn", | ||
"schema": "INSPIRE BAI" | ||
} | ||
], | ||
"name": { | ||
"value": "Smith, John", | ||
"preferred_name": "John Smith" | ||
}, | ||
"email_addresses": [ | ||
{ | ||
"value": "[email protected]", | ||
"current": True | ||
} | ||
] | ||
}, | ||
status=StatusChoices.RUNNING, | ||
core=True, | ||
is_update=False, | ||
|
@@ -405,32 +450,16 @@ def test_facets(self): | |
assert "_filter_status" in response.json()["facets"] | ||
assert "_filter_workflow_type" in response.json()["facets"] | ||
|
||
def test_search_status(self): | ||
self.api_client.force_authenticate(user=self.admin) | ||
|
||
url = ( | ||
reverse("search:workflow-list") + f"?search=status:{StatusChoices.RUNNING}" | ||
) | ||
|
||
response = self.api_client.get(url) | ||
|
||
for item in response.json()["results"]: | ||
print(item["status"]) | ||
assert item["status"] == StatusChoices.RUNNING | ||
|
||
def test_search_workflow_type(self): | ||
def test_search_data_name(self): | ||
self.api_client.force_authenticate(user=self.admin) | ||
|
||
url = ( | ||
reverse("search:workflow-list") | ||
+ f"?search=workflow_type:{WorkflowType.HEP_CREATE}" | ||
) | ||
url = reverse("search:workflow-list") + "?search=John" | ||
|
||
response = self.api_client.get(url) | ||
results = response.json()["results"] | ||
|
||
for item in response.json()["results"]: | ||
print(item["workflow_type"]) | ||
assert item["workflow_type"] == WorkflowType.HEP_CREATE | ||
assert len(results) == 1 | ||
assert results[0]["data"]["name"]["value"] == "Smith, John" | ||
|
||
def test_filter_status(self): | ||
self.api_client.force_authenticate(user=self.admin) | ||
|