-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: release 2.9.0 - adds workflow import (#164)
* first implementation * fixing params * improve error message * improve error message2 * improve error message3 * adding pytests * docs * typo * typo * doc improvement * doc improvement * doc improvement * doc improvement * improve docs * docs * docs * improving docs * improve help
- Loading branch information
Showing
11 changed files
with
359 additions
and
2 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '2.8.0' | ||
__version__ = '2.9.0' |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,74 @@ | ||
import mock | ||
import json | ||
import pytest | ||
import responses | ||
from cloudos.clos import Cloudos | ||
from cloudos.utils.errors import BadRequestException | ||
from tests.functions_for_pytest import load_json_file | ||
|
||
OUTPUT = "tests/test_data/workflows/workflow_import.json" | ||
APIKEY = 'vnoiweur89u2ongs' | ||
CLOUDOS_URL = 'http://cloudos.lifebit.ai' | ||
WORKSPACE_ID = 'lv89ufc838sdig' | ||
WORKFLOW_URL = 'https://github.com/lifebit-ai/repo' | ||
WORKFLOW_NAME = 'test-repo' | ||
REPOSITORY_PROJECT_ID = 1234 | ||
REPOSITORY_ID = 567 | ||
|
||
|
||
@mock.patch('cloudos.clos', mock.MagicMock()) | ||
@responses.activate | ||
def test_workflow_import_correct(): | ||
""" | ||
Test 'import_workflows' to work as intended | ||
API request is mocked and replicated with json files | ||
""" | ||
create_json = load_json_file(OUTPUT) | ||
search_str = f"teamId={WORKSPACE_ID}" | ||
# mock POST method with the .json | ||
responses.add( | ||
responses.POST, | ||
url=f"{CLOUDOS_URL}/api/v1/workflows?{search_str}", | ||
body=create_json, | ||
status=200) | ||
# start cloudOS service | ||
clos = Cloudos(apikey=APIKEY, cromwell_token=None, cloudos_url=CLOUDOS_URL) | ||
# get mock response | ||
workflow_id = clos.workflow_import(WORKSPACE_ID, | ||
WORKFLOW_URL, | ||
WORKFLOW_NAME, | ||
REPOSITORY_PROJECT_ID, | ||
REPOSITORY_ID) | ||
# check the response | ||
assert isinstance(workflow_id, str) | ||
assert workflow_id == '66156ba61d5f06a39b1da573' | ||
|
||
|
||
@mock.patch('cloudos.clos', mock.MagicMock()) | ||
@responses.activate | ||
def test_workflow_import_incorrect(): | ||
""" | ||
Test 'workflow_import' to fail with '400' response | ||
""" | ||
# prepare error message | ||
error_message = {"statusCode": 400, "code": "BadRequest", | ||
"message": "Bad Request.", "time": "2022-11-23_17:31:07"} | ||
error_json = json.dumps(error_message) | ||
search_str = f"teamId={WORKSPACE_ID}" | ||
# mock POST method with the .json | ||
responses.add( | ||
responses.POST, | ||
url=f"{CLOUDOS_URL}/api/v1/workflows?{search_str}", | ||
body=error_json, | ||
status=400) | ||
# raise 400 error | ||
with pytest.raises(BadRequestException) as error: | ||
# check if it failed | ||
clos = Cloudos(apikey=APIKEY, cromwell_token=None, | ||
cloudos_url=CLOUDOS_URL) | ||
clos.workflow_import(WORKSPACE_ID, | ||
WORKFLOW_URL, | ||
WORKFLOW_NAME, | ||
REPOSITORY_PROJECT_ID, | ||
REPOSITORY_ID) | ||
assert "Server returned status 400." in (str(error)) |
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 @@ | ||
{"_id":"66156ba61d5f06a39b1da573"} |