<s> import mock <EOL> from solum . api import auth <EOL> from solum . api . handlers import workflow_handler <EOL> from solum . openstack . common . fixture import config <EOL> from solum . tests import base <EOL> from solum . tests import fakes <EOL> from solum . tests import utils <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> class TestWorkflowHandler ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestWorkflowHandler , self ) . setUp ( ) <EOL> self . ctx = utils . dummy_context ( ) <EOL> self . CONF = self . useFixture ( config . Config ( ) ) <EOL> self . CONF . config ( auth_uri = '<STR_LIT>' , <EOL> group = auth . OPT_GROUP_NAME ) <EOL> self . CONF . config ( keystone_version = '<STR_LIT:3>' ) <EOL> def test_workflow_get ( self , mock_registry ) : <EOL> mock_registry . return_value . Workflow . get_by_uuid . return_value = { <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> handler = workflow_handler . WorkflowHandler ( self . ctx ) <EOL> res = handler . get ( '<STR_LIT>' ) <EOL> self . assertIsNotNone ( res ) <EOL> get_by_uuid = mock_registry . Workflow . get_by_uuid <EOL> get_by_uuid . assert_called_once_with ( self . ctx , '<STR_LIT>' ) <EOL> def test_workflow_get_all ( self , mock_reg ) : <EOL> mock_reg . WorkflowList . get_all . return_value = { } <EOL> handler = workflow_handler . WorkflowHandler ( self . ctx ) <EOL> res = handler . get_all ( app_id = '<STR_LIT>' ) <EOL> self . assertIsNotNone ( res ) <EOL> mock_reg . WorkflowList . get_all . assert_called_once_with ( self . ctx , <EOL> app_id = '<STR_LIT>' ) <EOL> def test_delete ( self , mock_registry ) : <EOL> db_obj = fakes . FakeWorkflow ( ) <EOL> mock_registry . Workflow . get_by_uuid . return_value = db_obj <EOL> handler = workflow_handler . WorkflowHandler ( self . ctx ) <EOL> handler . delete ( '<STR_LIT>' ) <EOL> mock_registry . Workflow . get_by_uuid . assert_called_once_with ( self . ctx , <EOL> '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_create ( self , mock_wf_insert , mock_pa , mock_registry ) : <EOL> app_obj = fakes . FakeApp ( ) <EOL> app_id = app_obj . id <EOL> test_cmd = app_obj . workflow_config [ '<STR_LIT>' ] <EOL> run_cmd = app_obj . workflow_config [ '<STR_LIT>' ] <EOL> mock_registry . App . get_by_id . return_value = app_obj <EOL> workflow_data = { "<STR_LIT>" : [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> "<STR_LIT>" : app_id , <EOL> "<STR_LIT:source>" : app_obj . source , <EOL> "<STR_LIT>" : app_obj . workflow_config , <EOL> "<STR_LIT>" : app_obj . trigger_actions } <EOL> fp = fakes . FakePlan ( ) <EOL> mock_registry . Plan . return_value = fp <EOL> fa = fakes . FakeAssembly ( ) <EOL> fa . plan_uuid = fp . uuid <EOL> mock_registry . Assembly . return_value = fa <EOL> wf_obj = fakes . FakeWorkflow ( ) <EOL> wf_obj . app_id = app_obj . id <EOL> wf_obj . assembly = fa . id <EOL> mock_registry . Workflow . return_value = wf_obj <EOL> fi = fakes . FakeImage ( ) <EOL> mock_registry . Image . return_value = fi <EOL> handler = workflow_handler . WorkflowHandler ( self . ctx ) <EOL> res = handler . create ( workflow_data , commit_sha = '<STR_LIT>' , status_url = '<STR_LIT>' , <EOL> du_id = '<STR_LIT>' ) <EOL> self . assertEqual ( wf_obj , res ) <EOL> git_info = { <EOL> '<STR_LIT>' : app_obj . source [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : app_obj . source [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> mock_pa . assert_called_once_with ( <EOL> verb = '<STR_LIT>' , workflow = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] , <EOL> build_id = fa . id , name = fi . name , assembly_id = fa . id , <EOL> git_info = git_info , test_cmd = test_cmd , ports = app_obj . ports , <EOL> base_image_id = fi . base_image_id , <EOL> source_format = fi . source_format , <EOL> image_format = fi . image_format , run_cmd = run_cmd , du_id = '<STR_LIT>' ) </s>
