Skip to content

Commit 77bfc9a

Browse files
author
Cloud User
committed
Created workflow unit test and added test to model_management for workflow error flow
1 parent b348b49 commit 77bfc9a

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/__init__.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/__main__.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/core.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/exceptions.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/services.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/tasks.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/__init__.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/cas_management.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/concepts.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/data_sources.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/files.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/folders.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/microanalytic_score.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/model_management.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/model_publish.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/model_repository.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/projects.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/sentiment_analysis.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/service.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/text_categorization.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/text_parsing.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/_services/workflow.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/__init__.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/astore.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/cli.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/pymas/__init__.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/pymas/core.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/pymas/ds2.py":[],"/home/centos/jamesfork/python-sasctl/.tox/py37-tests/lib/python3.7/site-packages/sasctl/utils/pymas/python.py":[]}}

tests/unit/test_model_management.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,20 @@ def test_table_prefix_format():
8282
# Underscores should not be allowed
8383
_ = mm.create_performance_definition('model',
8484
'TestLibrary',
85-
'invalid_name')
85+
'invalid_name')
86+
87+
def test_execute_model_workflow_definition_invalidworkflow():
88+
89+
PROJECT = RestObj({'name': 'Test Project', 'id': '98765'})
90+
WORKFLOWS = [{'name': 'Test W', 'id': '12345'},{'name': 'TestW2', 'id': '98765', 'prompts': [{'id': '98765', 'variableName': 'projectId', 'variableType': 'string'}]}]
91+
92+
with mock.patch('sasctl._services.workflow.Workflow'
93+
'.list_workflow_enableddefinitions') as list_workflow_enableddefinitions:
94+
with mock.patch('sasctl._services.model_repository.ModelRepository'
95+
'.get_project') as get_project:
96+
list_workflow_enableddefinitions.return_value = WORKFLOWS
97+
get_project.return_value = PROJECT
98+
with pytest.raises(ValueError):
99+
# Project missing
100+
_ = mm.execute_model_workflow_definition('TestLibrary','badworkflow')
101+

tests/unit/test_workflow.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python
2+
# encoding: utf-8
3+
#
4+
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
import pytest
8+
from six.moves import mock
9+
10+
from sasctl import RestObj
11+
from sasctl._services import workflow
12+
13+
14+
def test_list_workflow_prompt_invalidworkflow():
15+
16+
WORKFLOWS = [{'name': 'Test W', 'id': '12345'},{'name': 'TestW2', 'id': '98765', 'prompts': [{'id': '98765', 'variableName': 'projectId', 'variableType': 'string'}]}]
17+
wf = workflow.Workflow()
18+
19+
with mock.patch('sasctl._services.workflow.Workflow'
20+
'.list_workflow_enableddefinitions') as list_workflow_enableddefinitions:
21+
list_workflow_enableddefinitions.return_value = WORKFLOWS
22+
with pytest.raises(ValueError):
23+
# Project missing
24+
_ = wf.list_workflow_prompt('bad')
25+
26+
def test_list_workflow_prompt_workflownoprompt():
27+
28+
WORKFLOWS = [{'name': 'Test W', 'id': '12345'},{'name': 'TestW2', 'id': '98765', 'prompts': [{'id': '98765', 'variableName': 'projectId', 'variableType': 'string'}]}]
29+
wf = workflow.Workflow()
30+
31+
with mock.patch('sasctl._services.workflow.Workflow'
32+
'.list_workflow_enableddefinitions') as list_workflow_enableddefinitions:
33+
list_workflow_enableddefinitions.return_value = WORKFLOWS
34+
35+
#Testing no prompts on workflow with name
36+
testresult = wf.list_workflow_prompt('Test W')
37+
print(testresult)
38+
assert testresult is None
39+
40+
#Testing no prompts on workflow with id
41+
testresult = wf.list_workflow_prompt('12345')
42+
print(testresult)
43+
assert testresult is None
44+
45+
46+
47+
def test_list_workflow_prompt_workflowprompt():
48+
49+
WORKFLOWS = [{'name': 'Test W', 'id': '12345'},{'name': 'TestW2', 'id': '98765', 'prompts': [{'id': '98765', 'variableName': 'projectId', 'variableType': 'string'}]}]
50+
wf = workflow.Workflow()
51+
52+
with mock.patch('sasctl._services.workflow.Workflow'
53+
'.list_workflow_enableddefinitions') as list_workflow_enableddefinitions:
54+
list_workflow_enableddefinitions.return_value = WORKFLOWS
55+
56+
#Testing workflow with id and prompts
57+
testresult = wf.list_workflow_prompt('TestW2')
58+
print(testresult)
59+
assert testresult is not None
60+
61+
62+
#Testing workflow with id and prompts
63+
testresult = wf.list_workflow_prompt('98765')
64+
print(testresult)
65+
assert testresult is not None
66+

0 commit comments

Comments
 (0)