def test_validate_handle_types(stc): ctor = CScriptableCreator() stc_sys = CStcSystem.Instance() project = stc_sys.GetObject("Project") handle_list = [] # Empty handle list is valid (BLL will use project) assert learningCmd.validate_handle_types(handle_list, True, False) == '' port = ctor.Create("Port", project) handle_list = [port.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == '' assert learningCmd.validate_handle_types(handle_list, False, True) == '' assert learningCmd.validate_handle_types(handle_list, True, True) == '' stream = ctor.Create("StreamBlock", project) handle_list = [stream.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == '' assert learningCmd.validate_handle_types(handle_list, False, True) == '' assert learningCmd.validate_handle_types(handle_list, True, True) == '' host = ctor.Create("Host", project) handle_list = [host.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == \ "Invalid handle type: host. L2 learning command only " + \ "allows handles of type Port and StreamBlock" assert learningCmd.validate_handle_types(handle_list, False, True) == '' assert learningCmd.validate_handle_types(handle_list, True, True) == '' router = ctor.Create("Router", project) handle_list = [router.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == \ "Invalid handle type: router. L2 learning command only " + \ "allows handles of type Port and StreamBlock" assert learningCmd.validate_handle_types(handle_list, False, True) == '' assert learningCmd.validate_handle_types(handle_list, True, True) == '' emulated_device = ctor.Create("EmulatedDevice", project) handle_list = [emulated_device.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == \ "Invalid handle type: emulateddevice. L2 learning command only " + \ "allows handles of type Port and StreamBlock" assert learningCmd.validate_handle_types(handle_list, False, True) == '' assert learningCmd.validate_handle_types(handle_list, True, True) == '' invalid = ctor.Create("BgpRouterConfig", emulated_device) handle_list = [invalid.GetObjectHandle()] assert learningCmd.validate_handle_types(handle_list, True, False) == \ "Invalid handle type: bgprouterconfig. L2 learning command only " + \ "allows handles of type Port and StreamBlock" assert learningCmd.validate_handle_types(handle_list, False, True) == \ "Invalid handle type: bgprouterconfig. Learning command only allows handles " + \ "of type Port, StreamBlock, Host, Router, and EmulatedDevice" assert learningCmd.validate_handle_types(handle_list, True, True) == \ "Invalid handle type: bgprouterconfig. Learning command only allows handles " + \ "of type Port, StreamBlock, Host, Router, and EmulatedDevice" return