def test_build_iteration_framework_property_chains_simple_group(stc): ctor = CScriptableCreator() stc_sys = CStcSystem.Instance() sequencer = stc_sys.GetObject("Sequencer") # Sequencer Command List will look as follows: # # IteratorValidateCommand # SequencerGroupCommand # SequencerWhileCommand # ObjectIteratorCommand # IteratorConfigCommand # IteratorConfigCommand # CreateTemplateConfigCommand # IteratorValidateCommand # IteratorValidateCommand # IteratorValidateCommand cmd = ctor.Create(TM_PKG + ".IteratorValidateCommand", sequencer) # SequencerGroupCommand group_cmd = ctor.Create("SequencerGroupCommand", sequencer) # IteratorCommand while_cmd = ctor.Create("SequencerWhileCommand", group_cmd) iter_cmd = ctor.Create(TM_PKG + ".ObjectIteratorCommand", while_cmd) config_cmd = ctor.Create(TM_PKG + ".IteratorConfigCommand", while_cmd) config_cmd2 = ctor.Create(TM_PKG + ".IteratorConfigCommand", while_cmd) cmd2 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", while_cmd) valid_cmd = ctor.Create(TM_PKG + ".IteratorValidateCommand", while_cmd) while_cmd.Set("ExpressionCommand", iter_cmd.GetObjectHandle()) while_cmd.SetCollection("CommandList", [config_cmd.GetObjectHandle(), config_cmd2.GetObjectHandle(), cmd2.GetObjectHandle(), valid_cmd.GetObjectHandle()]) cmd4 = ctor.Create(TM_PKG + ".IteratorValidateCommand", group_cmd) group_cmd.SetCollection("CommandList", [while_cmd.GetObjectHandle(), cmd4.GetObjectHandle()]) cmd5 = ctor.Create(TM_PKG + ".IteratorValidateCommand", sequencer) sequencer.SetCollection("CommandList", [cmd.GetObjectHandle(), group_cmd.GetObjectHandle(), cmd5.GetObjectHandle()]) # Build the property chains iter_utils.build_iteration_framework_property_chains( sequencer.GetCollection("CommandList")) # Check the property chains check_iter_to_config_chain(iter_cmd, [config_cmd, config_cmd2]) check_valid_to_iter_chain(valid_cmd, iter_cmd) check_iter_to_valid_chain(iter_cmd, [valid_cmd])
def test_build_iteration_framework_property_chains_complex(stc): ctor = CScriptableCreator() stc_sys = CStcSystem.Instance() sequencer = stc_sys.GetObject("Sequencer") # Sequencer Command List will look as follows: # # SequencerGroupCommand # CreateTemplateConfigCommand # CreateTemplateConfigCommand # SequencerWhileCommand # ObjectIteratorCommand # IteratorConfigCommand # IteratorConfigCommand # CreateTemplateConfigCommand # WaitForPropertyValueCommand # SequencerGroupCommand # SequencerWhileCommand # ObjectIteratorCommand # IteratorConfigCommand # IteratorValidateCommand # SequencerGroupCommand # SequencerWhileCommand # Dhcpv6BindWaitCommand # CreateTemplateConfigCommand # IteratorValidateCommand # SequencerGroupCommand # SequencerWhileCommand # ObjectIteratorCommand # IteratorValidateCommand # CreateTemplateConfigCommand # IteratorValidateCommand # IteratorValidateCommand # IteratorValidateCommand # IteratorValidateCommand # IteratorValidateCommand # Group Command group_cmd5 = ctor.Create("SequencerGroupCommand", sequencer) # Set up a sequence cmd1 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", group_cmd5) cmd2 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", group_cmd5) # (outer) IteratorCommand while_cmd = ctor.Create("SequencerWhileCommand", group_cmd5) iter_cmd = ctor.Create(TM_PKG + ".ObjectIteratorCommand", while_cmd) config_cmd = ctor.Create(TM_PKG + ".IteratorConfigCommand", while_cmd) config_cmd2 = ctor.Create(TM_PKG + ".IteratorConfigCommand", while_cmd) cmd3 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", while_cmd) cmd4 = ctor.Create(TM_PKG + ".WaitForPropertyValueCommand", while_cmd) # Group Command group_cmd = ctor.Create("SequencerGroupCommand", while_cmd) # (inner) IteratorCommand while_cmd2 = ctor.Create("SequencerWhileCommand", group_cmd) iter_cmd2 = ctor.Create(TM_PKG + ".ObjectIteratorCommand", while_cmd2) config_cmd3 = ctor.Create(TM_PKG + ".IteratorConfigCommand", while_cmd2) valid_cmd2 = ctor.Create(TM_PKG + ".IteratorValidateCommand", while_cmd2) while_cmd2.Set("ExpressionCommand", iter_cmd2.GetObjectHandle()) while_cmd2.SetCollection("CommandList", [config_cmd3.GetObjectHandle(), valid_cmd2.GetObjectHandle()]) # (inner) Group Command group_cmd2 = ctor.Create("SequencerGroupCommand", group_cmd) while_cmd3 = ctor.Create("SequencerWhileCommand", group_cmd2) pass_fail_cmd = ctor.Create("Dhcpv6BindWaitCommand", while_cmd3) cmd5 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", while_cmd3) # Nested combined command group_cmd15 = ctor.Create("SequencerGroupCommand", while_cmd3) while_cmd15 = ctor.Create("SequencerWhileCommand", group_cmd15) combined_cmd15 = ctor.Create(TM_PKG + ".ObjectIteratorCommand", while_cmd15) valid_cmd15 = ctor.Create(TM_PKG + ".IteratorValidateCommand", while_cmd15) while_cmd15.Set("ExpressionCommand", combined_cmd15.GetObjectHandle()) while_cmd15.SetCollection("CommandList", [valid_cmd15.GetObjectHandle()]) group_cmd15.SetCollection("CommandList", [while_cmd15.GetObjectHandle()]) valid_cmd3 = ctor.Create(TM_PKG + ".IteratorValidateCommand", while_cmd3) while_cmd3.Set("ExpressionCommand", pass_fail_cmd.GetObjectHandle()) while_cmd3.SetCollection("CommandList", [cmd5.GetObjectHandle(), group_cmd15.GetObjectHandle(), valid_cmd3.GetObjectHandle()]) cmd6 = ctor.Create(TM_PKG + ".CreateTemplateConfigCommand", group_cmd2) group_cmd2.SetCollection("CommandList", [while_cmd3.GetObjectHandle(), cmd6.GetObjectHandle()]) cmd7 = ctor.Create(TM_PKG + ".IteratorValidateCommand", group_cmd) group_cmd.SetCollection("CommandList", [while_cmd2.GetObjectHandle(), group_cmd2.GetObjectHandle(), cmd7.GetObjectHandle()]) valid_cmd4 = ctor.Create(TM_PKG + ".IteratorValidateCommand", while_cmd) while_cmd.Set("ExpressionCommand", iter_cmd.GetObjectHandle()) while_cmd.SetCollection("CommandList", [config_cmd.GetObjectHandle(), config_cmd2.GetObjectHandle(), cmd3.GetObjectHandle(), cmd4.GetObjectHandle(), group_cmd.GetObjectHandle(), valid_cmd4.GetObjectHandle()]) cmd8 = ctor.Create(TM_PKG + ".IteratorValidateCommand", group_cmd5) cmd9 = ctor.Create(TM_PKG + ".IteratorValidateCommand", group_cmd5) group_cmd5.SetCollection("CommandList", [cmd1.GetObjectHandle(), cmd2.GetObjectHandle(), while_cmd.GetObjectHandle(), cmd8.GetObjectHandle(), cmd9.GetObjectHandle()]) cmd10 = ctor.Create(TM_PKG + ".IteratorValidateCommand", sequencer) sequencer.SetCollection("CommandList", [group_cmd5.GetObjectHandle(), cmd10.GetObjectHandle()]) # Build the property chains iter_utils.build_iteration_framework_property_chains( sequencer.GetCollection("CommandList")) # Check the property chains check_iter_to_config_chain(iter_cmd, [config_cmd, config_cmd2]) check_valid_to_iter_chain(valid_cmd4, iter_cmd) check_iter_to_valid_chain(iter_cmd, [valid_cmd4]) check_iter_to_config_chain(iter_cmd2, [config_cmd3]) check_valid_to_iter_chain(valid_cmd2, iter_cmd2) check_iter_to_valid_chain(iter_cmd2, [valid_cmd2]) # Check lack of property chains (negative test) prop_chain_list = while_cmd3.GetObjects("PropertyChainingConfig") assert prop_chain_list == []