def test_run(stc): sequencer = CStcSystem.Instance().GetObject("Sequencer") project = CStcSystem.Instance().GetObject("Project") ctor = CScriptableCreator() hnd_reg = CHandleRegistry.Instance() cmd = ctor.Create(PKG + ".CreateProtocolMixCommand2", sequencer) plLogger = PLLogger.GetLogger("test_CreateProtocolMixCommand2.test_run") plLogger.LogInfo("start") CreateProtoMixCmd.get_this_cmd = MagicMock(return_value=cmd) ret_val = CreateProtoMixCmd.run(get_example_mix_info(), "UnitTestProtoMix", "", False) assert cmd.Get("Status") == "" assert ret_val # Check the created StmTemplateMix mix_hnd = cmd.Get('StmTemplateMix') mix = hnd_reg.Find(mix_hnd) assert mix assert mix.Get('MixInfo') == get_example_mix_info() # Find the tagged commands tag_json = cmd.Get("GroupCommandTagInfo") assert tag_json != "" tag_dict = json_utils.load_json(tag_json) tagged_obj_list = tag_utils.get_tagged_objects_from_string_names( [tag_dict["rowIterator"]]) assert len(tagged_obj_list) == 1 obj_iter = tagged_obj_list[0] assert obj_iter.IsTypeOf(PKG + ".ObjectIteratorCommand") assert obj_iter.Get("StepVal") == 1 assert obj_iter.Get("MaxVal") == 0.0 assert obj_iter.Get("MinVal") == 0.0 assert obj_iter.Get("IterMode") == "STEP" assert obj_iter.Get("ValueType") == "RANGE" tagged_obj_list = tag_utils.get_tagged_objects_from_string_names( [tag_dict["rowConfigurator"]]) assert len(tagged_obj_list) == 1 config_cmd = tagged_obj_list[0] assert config_cmd.IsTypeOf(PKG + ".IteratorConfigMixParamsCommand") assert mix_hnd == config_cmd.Get('StmTemplateMix') # Check the created StmProtocolMix proto_mix_hnd = cmd.Get("StmTemplateMix") proto_mix = hnd_reg.Find(proto_mix_hnd) assert proto_mix # Check the Tag tags = project.GetObject("Tags") assert tags user_tag_list = tags.GetObjects("Tag") assert len(user_tag_list) exp_tag = None for user_tag in user_tag_list: if user_tag.Get("Name") == "UnitTestProtoMix": exp_tag = user_tag break assert exp_tag tag_target = exp_tag.GetObject("StmTemplateMix", RelationType("UserTag", 1)) assert tag_target assert tag_target.GetObjectHandle() == proto_mix.GetObjectHandle() tagged_obj_list = tag_utils.get_tagged_objects_from_string_names( [tag_dict["templateConfigurator"]]) assert len(tagged_obj_list) == 1 ctc_cmd = tagged_obj_list[0] assert ctc_cmd.IsTypeOf(PKG + ".CreateTemplateConfigCommand") ctc_input_mix_hnd = ctc_cmd.Get("StmTemplateMix") assert ctc_input_mix_hnd == proto_mix.GetObjectHandle()