How to use setCodeFileLine method in fMBT

Best Python code snippet using fMBT_python

remote_pyaal

Source:remote_pyaal Github

copy

Full Screen

1#!/usr/bin/env python2#3# fMBT, free Model Based Testing tool4# Copyright (c) 2011, Intel Corporation.5#6# This program is free software; you can redistribute it and/or modify it7# under the terms and conditions of the GNU Lesser General Public License,8# version 2.1, as published by the Free Software Foundation.9#10# This program is distributed in the hope it will be useful, but WITHOUT11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for13# more details.14#15# You should have received a copy of the GNU Lesser General Public License along with16# this program; if not, write to the Free Software Foundation, Inc.,17# 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.18"""19Usage: remote_pyaal [options] aalfile20Runs remote model & adapter written in AAL/Python. aalfile is a21AAL/Python file or Python generated by fmbt-aalc.22Options:23 -c <string>24 execute the string in the Python interpreter before loading25 aalfile.26 -D flag27 pass -D flag to AAL compiler and preprocessor, used in ifdef's.28 -I include-dir29 Pass -I include-dir to AAL compiler and preprocessor. If AAL30 contains ^include "filename"'s, filename will be looked for in31 include-dir.32 -l, -L, --log-file= filename33 Write log to the given file. By default no log is written.34 -l , --log-file overwrites the file, -L appends.35 -t, --timeout s36 Event observation timeout in seconds.37 -o, --output filename38 Convert AAL/Python model to LSTS and write output to given39 file. If filename is "-", output is written to the standard40 output.41 --lsts-depth n42 Stop AAL/Python to LSTS conversion to the given depth. The43 depth is the number of test steps from the initial state.44 -H, --lsts-hide-var varname45 Ignore value of varname when converting to LSTS. States which46 differ only by ignored variables are considered the47 same. --lsts-hide-var can be given several times.48 -S, --lsts-show-var varname49 Take variable varname into account when converting to50 LSTS. --lsts-show-var can be given several times.51 -d, --debug52 Run in debug mode.53"""54import sys55import os56import getopt57import subprocess58import inspect59import time60import fmbt61import atexit62import re63import urllib64import tempfile65import traceback66import StringIO67sys.path.append(os.getcwd())68opt_debug = False69filter_tags = []70log_filename = None71log_flush_interval = 1.0 # in seconds72def _log(msg, flush=False):73 global log_filename74 if opt_debug:75 fmbt._adapterlogWriter(file(log_filename,"a"), fmbt.formatAdapterLogMessage(msg))76 return77 current_time = time.time()78 if log_filename:79 _log.messages.append(fmbt.formatAdapterLogMessage(msg))80 if flush or current_time - _log.last_flush > log_flush_interval:81 log_fileobj = file(log_filename, "a")82 for formatted_msg in _log.messages:83 fmbt._adapterlogWriter(log_fileobj, formatted_msg)84 log_fileobj.close()85 _log.last_flush = current_time86 _log.messages = []87_log.messages = []88_log.last_flush = time.time()89def fmbtlog(msg, flush=True):90 current_time = time.time()91 timestamped = "fmbtmagicl%.4f %s" % (current_time, msg)92 sys.stdout.write(urllib.quote(timestamped)+"\n")93def fmbtstderr(msg):94 to_fmbt = urllib.quote("fmbtmagice%s" % (msg,)) + '\n'95 sys.stdout.write(to_fmbt)96 _log(msg)97fmbt.fmbtlog = fmbtlog98fmbt.adapterlog = _log99log = _log100def error(msg):101 msg = "remote_pyaal error: " + msg + "\n"102 _log(msg)103 sys.stderr.write(msg)104 sys.exit(1)105def bye():106 _g_bridge._aal.aexit(None, None)107 _log("quitting", flush=True)108def put(msg):109 if opt_debug: _log("sending: '%s'" % (msg,))110 sys.stdout.write("fmbtmagic " + str(msg) + "\n")111 sys.stdout.flush()112def put_list(list_of_integers):113 msg = " ".join([str(i) for i in list_of_integers])114 if opt_debug: _log("sending: '%s'" % (msg,))115 sys.stdout.write("fmbtmagic " + msg + "\n")116 sys.stdout.flush()117def put_lts(lts_string):118 if opt_debug: _log("sending lts")119 sys.stdout.write("fmbtmagic %s\n%s" % (len(lts_string), lts_string))120 sys.stdout.flush()121def get():122 cmd = sys.stdin.readline().rstrip()123 if opt_debug: _log("received: '%s'" % (cmd,))124 return cmd125class RemoteAALBridge:126 def __init__(self, aal):127 self._aal = aal128 def communicate(self):129 # send all action names130 action_names = self._aal.getActionNames()131 for name in action_names:132 put(name)133 put("")134 # send all state tags135 tag_names = self._aal.getSPNames()136 for name in tag_names:137 put(name)138 put("")139 # protocol loop140 adapter_call_arguments = []141 cmd = get()142 while cmd != "":143 if cmd == "ma":144 try:145 put_list(self._aal.getActions())146 except Exception, e:147 report_simulation_error(self._aal)148 fmbtstderr('Error when evaluating guards of actions: %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))149 error(str(e))150 elif cmd == "mp":151 try: put_list(self._aal.getprops())152 except Exception, e:153 report_simulation_error(self._aal)154 fmbtstderr('Error at a tag: %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))155 error(str(e))156 elif cmd == "mr":157 try: self._aal.reset()158 except Exception, e:159 fmbtstderr('Error at initial_state(): %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))160 put(0)161 else: put(1)162 elif cmd == "mu":163 self._aal.push()164 elif cmd == "mo":165 self._aal.pop()166 elif cmd.startswith("ae"):167 try:168 args = cmd[3:]169 if " " in args: verdict, reason = args.split(" ", 1)170 else: verdict, reason = args, ""171 self._aal.aexit(verdict, urllib.unquote(reason))172 except Exception, e:173 fmbtstderr('Error at adapter_exit(): %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))174 put(0)175 else:176 put(1)177 elif cmd == "ai":178 try: rv = self._aal.init()179 except Exception, e:180 fmbtstderr('Error at adapter_init(): %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))181 put(0)182 else:183 if rv or rv == None: put(1)184 else: put(0)185 elif cmd == "aop":186 try:187 put_list(self._aal.observe(False))188 except Exception, e:189 fmbtstderr('Error when polling outputs: %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))190 error(str(e))191 elif cmd == "aob":192 try:193 put_list(self._aal.observe(True))194 except Exception, e:195 fmbtstderr('Error when waiting for outputs: %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))196 error(str(e))197 elif cmd.startswith("act"): # adapter check tags198 # If the adapter of a tag does not return "True" or199 # None, report the number of the first failing tag.200 failing_tags = []201 for tag_number in [int(n) for n in cmd[3:].strip().split()]:202 try:203 rv = self._aal.tag_execute(tag_number)204 if not (rv or rv == None):205 fmbtstderr('adapter() of tag "%s" returned %s' % (tag_names[tag_number-1], rv))206 failing_tags.append(tag_number)207 except Exception, e:208 if isinstance(e, AssertionError): msg = "Assertion failure"209 else: msg = "Error"210 fmbtstderr('%s at adapter() of tag "%s": %s\n%s' % (msg, tag_names[tag_number-1], e, format_pythonaalexception()))211 if isinstance(e, AssertionError):212 failing_tags.append(tag_number)213 else:214 error(str(e))215 put_list(failing_tags)216 elif cmd[0] == "m":217 action_number = int(cmd[1:])218 try:219 rv = self._aal.model_execute(action_number)220 except Exception, e:221 report_simulation_error(self._aal)222 fmbtstderr('Error at body() of "%s": %s: %s\n%s' % (action_names[action_number-1], type(e).__name__, e, format_pythonaalexception()))223 error(str(e))224 else:225 put(rv)226 elif cmd[:2] == "ap":227 adapter_call_arguments.append(cmd[2:])228 elif cmd[0] == "a":229 action_number = int(cmd[1:])230 try:231 rv = self._aal.adapter_execute(action_number,232 adapter_call_arguments)233 if (type(rv) == int and (rv == 0 or rv > len(action_names))) or (type(rv) != int and (not rv or rv != None)):234 fmbtstderr('adapter() of action "%s" returned %s' % (action_names[action_number-1], rv))235 rv = 0236 except Exception, e:237 if isinstance(e, AssertionError): msg = "Assertion failure"238 else: msg = "Error"239 fmbtstderr('%s at adapter() of "%s": %s: %s\n%s' % (msg, action_names[action_number-1], type(e).__name__, e, format_pythonaalexception()))240 if isinstance(e, AssertionError):241 rv = 0242 else:243 error(str(e))244 put(rv)245 adapter_call_arguments = []246 elif cmd.startswith("lts"):247 lsts_depth = int(cmd[3:])248 outfilestring = StringIO.StringIO()249 try:250 self._aal.push()251 aal2lsts(self._aal, outfilestring, lsts_depth,252 include_generation_discontinued_tag = False)253 self._aal.pop()254 except Exception, e:255 report_simulation_error(self._aal)256 fmbtstderr('Error on simulation %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))257 error(str(e))258 outfilestring.seek(0)259 put_lts(outfilestring.read())260 else:261 error("Unexpected command: \"" + cmd + "\". remote_pyaal works with \"aal_remote\" model.")262 cmd = get().rstrip()263def format_pythonaalexception():264 if opt_debug:265 # return full tracebacks including framework code266 return traceback.format_exc()267 exc_type, exc_value, exc_tb = sys.exc_info()268 tb = traceback.extract_tb(exc_tb)269 tb.reverse()270 new_tb = []271 for file_line_module_code in tb:272 if file_line_module_code[0].endswith("aalmodel.py"):273 break274 new_tb.append(file_line_module_code)275 new_tb.reverse()276 return 'Traceback (most recent call last):\n' + ''.join(traceback.format_list(new_tb))277def format_syntaxerror():278 """modify last exception filename and line number if it's AAL"""279 redefline = re.compile(' def [a-z0-9_]+\(\):')280 recodefileline = re.compile('setCodeFileLine\(.*\'\'\'(.*)\'\'\', ([-0-9]+)[^0-9]')281 exc_type, exc_value, exc_tb = sys.exc_info()282 tb_tuples = traceback.extract_tb(exc_tb)283 filename, syntaxerrorlineno = exc_value.filename, exc_value.lineno284 try:285 fullsource = file(filename).read()286 fullsourcelines = fullsource.split('\n')287 # syntax error is inside the block that starts on line deflineno288 defline = redefline.findall('\n'.join(fullsourcelines[:syntaxerrorlineno-1]))[-1]289 deflineno = fullsourcelines.index(defline) + 1290 # that block defined is in an aal file given on next setCodeFileLine291 codefile, aalblockstart = recodefileline.findall('\n'.join(fullsourcelines[syntaxerrorlineno-1:]))[0]292 aalblocklineno = syntaxerrorlineno - deflineno293 exc_value.lineno = int(aalblockstart) + aalblocklineno294 exc_value.filename = codefile295 exc_value.args = (exc_value.args[0],296 (exc_value.filename, exc_value.lineno, exc_value.args[1][2], exc_value.args[1][3]))297 sys.last_value = exc_value298 except:299 pass300def report_simulation_error(aal):301 if len(aal._stack_executed_actions) > 0:302 executed_actions = []303 for l in aal._stack_executed_actions:304 executed_actions.extend(l)305 fmbtstderr("Error after simulated execution:\n %s" % ('\n '.join(executed_actions)))306def tagfilter(state,tags):307 global filter_tags308 for tag in filter_tags:309 if tag in tags:310 return tag311 return state312def aal2lsts(aal, output_fileobj, depth=5, discard_variables=set([]),313 include_variables=None, include_generation_discontinued_tag=True,_filter_tags=[]):314 global filter_tags315 try:316 import lsts317 except:318 import fmbt.lsts as lsts319 def update_generated_tags(aal, include_variables,320 generated_tagnames, tags, new_lsts_state_num):321 for v in include_variables:322 t = "var:%s = %s" % (v, str(aal._variables[v])[:42])323 if not t in generated_tagnames:324 generated_tagnames.add(t)325 tags[t] = []326 tags[t].append(new_lsts_state_num)327 generation_discontinued_tag = "AAL-depth:%s" % (depth,)328 new_lsts = lsts.writer()329 actionnames = ["tau"] + aal.getActionNames()330 # actionname2int = dict([(action, num) for num, action in enumerate(actionnames)])331 transitions = [[]]332 tags = {generation_discontinued_tag: []}333 tagnames = aal.getSPNames()334 generated_tagnames = set([])335 tags.update([(name, []) for name in tagnames])336 tagnum_to_name = dict([(num+1, name) for num, name in enumerate(tagnames)])337 for num,_t in enumerate(tagnames,1):338 if _t in _filter_tags:339 filter_tags.append(num)340 current_tags = aal.getprops()341 initial_state_hidden = tagfilter(aal.state(discard_variables, include_variables), current_tags)342 initial_state_real = aal.state()343 unhandled_states = {initial_state_real: []} # state to shortest path from istate344 found_states_real = {initial_state_real: initial_state_hidden} # real to hidden states345 lsts_states = {initial_state_hidden: 0} # state to LSTS state number346 states = 1347 # initial state tags348 for tag in current_tags:349 tags[tagnum_to_name[tag]].append(lsts_states[initial_state_hidden])350 if include_variables:351 update_generated_tags(aal, include_variables, generated_tagnames, tags, 0)352 while unhandled_states:353 source_state, path = unhandled_states.popitem()354 source_lsts_state = lsts_states[found_states_real[source_state]]355 if len(path) >= depth:356 if not source_lsts_state in tags[generation_discontinued_tag]:357 tags[generation_discontinued_tag].append(lsts_states[found_states_real[source_state]])358 continue359 aal.push()360 for action in path:361 aal.model_execute(action)362 for action in aal.getActions():363 aal.push()364 aal.model_execute(action)365 current_tags = aal.getprops()366 next_state_real = aal.state()367 next_state_hidden = tagfilter(aal.state(discard_variables, include_variables) ,current_tags)368 # new state?369 if not next_state_hidden in lsts_states:370 transitions.append([])371 new_lsts_state_num = len(transitions) - 1372 lsts_states[next_state_hidden] = new_lsts_state_num373 if include_variables:374 update_generated_tags(aal, include_variables, generated_tagnames, tags, new_lsts_state_num)375 if not next_state_real in found_states_real:376 unhandled_states[next_state_real] = path + [action]377 found_states_real[next_state_real] = next_state_hidden378 next_lsts_state_num = lsts_states[next_state_hidden]379 for tag in current_tags:380 tagname = tagnum_to_name[tag]381 if not next_lsts_state_num in tags[tagname]:382 tags[tagname].append(next_lsts_state_num)383 if (lsts_states[next_state_hidden],action) not in transitions[source_lsts_state]:384 transitions[source_lsts_state].append((lsts_states[next_state_hidden],action))385 aal.pop()386 aal.pop()387 new_lsts.set_actionnames(actionnames)388 new_lsts.set_transitions(transitions)389 new_lsts.set_stateprops(tags)390 stateprop_order = aal.getSPNames() + sorted(generated_tagnames)391 if include_generation_discontinued_tag:392 stateprop_order.append(generation_discontinued_tag)393 new_lsts.write(output_fileobj, stateprop_order=stateprop_order)394if __name__ == "__main__":395 # Default values for commandline arguments396 log_filename = None397 opt_timeout = 1.0398 opt_ppflags = []399 opt_output_fileobj = None400 opt_lsts_depth = 5401 opt_lsts_hide_vars = []402 opt_lsts_show_vars = []403 opt_c_exec_statements = []404 opt_lsts_hide_tags = []405 # Parse arguments406 opts, remainder = getopt.gnu_getopt(407 sys.argv[1:], 'c:dhl:L:t:o:D:H:S:VT:I:',408 ["debug", "help", "log-file=", "timeout=", "output=",409 "lsts-depth=", "lsts-hide-var=", "lsts-show-var=", "version"])410 for opt, arg in opts:411 if opt in ["-T"]:412 opt_lsts_hide_tags.append(arg)413 elif opt in ["-d", "--debug"]:414 opt_debug = True415 elif opt in ["-c"]:416 opt_c_exec_statements.append(arg)417 elif opt in ["-D"]:418 opt_ppflags += ['-D' , arg]419 elif opt in ["-I"]:420 opt_ppflags += ['-I' , arg]421 elif opt in ['-V', '--version']:422 try:423 import fmbt_config424 print "Version " + fmbt_config.fmbt_version + fmbt_config.fmbt_build_info425 except:426 print "Version N/A"427 sys.exit(0)428 elif opt in ["-h", "--help"]:429 print __doc__430 sys.exit(0)431 elif opt in ["-l", "-L", "--log-file"]:432 log_filename = arg433 if opt != "-L": file(log_filename, "w") # overwrite434 elif opt in ["-t", "--timeout"]:435 opt_timeout = float(arg)436 _log("observe timeout: %2.6f" % (opt_timeout,))437 elif opt in ["-o", "--output"]:438 if arg == "-":439 opt_output_fileobj = sys.stdout440 else:441 opt_output_fileobj = file(arg, "w")442 elif opt in ["--lsts-depth"]:443 opt_lsts_depth = int(arg)444 elif opt in ["-H", "--lsts-hide-var"]:445 opt_lsts_hide_vars.append(arg)446 elif opt in ["-S", "--lsts-show-var"]:447 opt_lsts_show_vars.append(arg)448 if len(remainder) != 1:449 print __doc__450 error("aal filename missing")451 aal_filename = remainder[0]452 if aal_filename.endswith(".aal"):453 cmd = ["fmbt-aalc"] + opt_ppflags + [ aal_filename ]454 subout = subprocess.PIPE455 p = subprocess.Popen(cmd,shell=False, stdout=subout,stderr=subout)456 aal_code = p.stdout.read()457 status = p.wait()458 if status != 0:459 fmbtstderr("AAL to Python conversion failed:\n%s" % (aal_code,))460 error("converting aal to python with command\n" +461 " %s\nfailed. status=%s" % (cmd, status))462 else:463 try:464 aal_code = file(aal_filename).read()465 except Exception as e:466 error("reading file '%s' failed: %s" % (aal_filename, e))467 for statement in opt_c_exec_statements:468 try:469 _log("Executing command line argument '%s'" % statement)470 exec statement471 except Exception, e:472 fmbtstderr('Exception from command line argument "%s":\n%s' %473 (statement, traceback.format_exc()))474 error("No exceptions allowed, got '%s':\n%s" %475 (e, traceback.format_exc()))476 aalpy_fd, aalpy_filename = tempfile.mkstemp(suffix='.py', prefix='remote_pyaal.')477 os.write(aalpy_fd, aal_code)478 os.close(aalpy_fd)479 atexit.register(lambda: os.remove(aalpy_filename))480 try:481 exec file(aalpy_filename)482 except Exception as e:483 if isinstance(e, SyntaxError):484 format_syntaxerror()485 code_lines = aal_code.split('\n')486 code_with_line_nums = ['%4s: %s' % (num+1, line)487 for num,line in enumerate(code_lines)]488 _log('\n'.join(code_with_line_nums))489 fmbtstderr("Executing %s failed: %s: %s\n%s" %490 (aal_filename, type(e).__name__, e, traceback.format_exc()))491 error("executing aal code failed:\n%s\n%s" % (e, traceback.format_exc()))492 try:493 # Generated AAL code exports generated AAL class as "Model".494 # Model is inherited from AALModel in aalmodel.py.495 aal = Model()496 except Exception as e:497 error("Error when instantiating Model(): %s\n%s" % (e, traceback.format_exc()))498 aal._log = _log499 aal.timeout = opt_timeout500 aal._variables['fmbtlog'] = fmbtlog501 aal._variables['__file__'] = aal_filename502 if not opt_output_fileobj:503 _g_bridge = RemoteAALBridge(aal)504 _log("starting")505 atexit.register(bye)506 if sys.platform == "win32":507 import os, msvcrt508 msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)509 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)510 msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)511 suffix=".dll"512 _g_bridge.communicate()513 else:514 aal.reset()515 try:516 aal2lsts(aal, opt_output_fileobj, depth=opt_lsts_depth, discard_variables=set(opt_lsts_hide_vars), include_variables=set(opt_lsts_show_vars),_filter_tags=opt_lsts_hide_tags)517 except Exception, e:518 report_simulation_error(aal)519 fmbtstderr('Error on simulation %s: %s\n%s' % (type(e).__name__, e, format_pythonaalexception()))...

Full Screen

Full Screen

github.aal.py

Source:github.aal.py Github

copy

Full Screen

...12 global state, approved, SUT13 state = PRState.NONE14 approved = 015 pass16 initial_state1.func_code = aalmodel.setCodeFileLine(initial_state1.func_code, '''github.aal''', 7)17 initial_state_list.append(initial_state1)18 push_variables_set.update(initial_state1.func_code.co_names)19 def adapter_init1():20 global state, approved, SUT21 log("Start")22 SUT=GithubPR("Kokan/github-fmbt")23 return 124 adapter_init1.func_code = aalmodel.setCodeFileLine(adapter_init1.func_code, '''github.aal''', 11)25 adapter_init_list.append(adapter_init1)26 def adapter_exit1(verdict,reason):27 global state, approved, SUT28 if verdict == "pass":29 log("PASS")30 log("cleaning up ")31 pass32 adapter_exit1.func_code = aalmodel.setCodeFileLine(adapter_exit1.func_code, '''github.aal''', 15)33 adapter_exit_list.append(adapter_exit1)34 action1name = "i:Open new PR"35 action1type = "input"36 def action1guard():37 global state, approved, SUT38 action_name = "i:Open new PR"39 input_name ="Open new PR"40 action_index = 041 return (state in [PRState.NONE, PRState.CLOSED, PRState.MERGED])42 action1guard.requires = []43 action1guard.func_code = aalmodel.setCodeFileLine(action1guard.func_code, '''github.aal''', 17, "guard of action \"i:Open new PR\"")44 def action1body():45 global state, approved, SUT46 action_name = "i:Open new PR"47 input_name ="Open new PR"48 action_index = 049 state = PRState.OPEN50 approved = 051 action1body.func_code = aalmodel.setCodeFileLine(action1body.func_code, '''github.aal''', 23, "body of action \"i:Open new PR\"")52 def action1adapter():53 global state, approved, SUT54 action_name = "i:Open new PR"55 input_name ="Open new PR"56 action_index = 057 prid = SUT.OpenNewPR()58 log("Create PR {}".format(p))59 return 160 action1adapter.func_code = aalmodel.setCodeFileLine(action1adapter.func_code, '''github.aal''', 19, "adapter of action \"i:Open new PR\"")61 action2name = "i:Merge PR"62 action2type = "input"63 def action2guard():64 global state, approved, SUT65 action_name = "i:Merge PR"66 input_name ="Merge PR"67 action_index = 068 return ((state == PRState.OPEN) and (approved>0))69 action2guard.requires = []70 action2guard.func_code = aalmodel.setCodeFileLine(action2guard.func_code, '''github.aal''', 28, "guard of action \"i:Merge PR\"")71 def action2body():72 global state, approved, SUT73 action_name = "i:Merge PR"74 input_name ="Merge PR"75 action_index = 076 state = PRState.MERGED77 action2body.func_code = aalmodel.setCodeFileLine(action2body.func_code, '''github.aal''', 33, "body of action \"i:Merge PR\"")78 def action2adapter():79 global state, approved, SUT80 action_name = "i:Merge PR"81 input_name ="Merge PR"82 action_index = 083 log("Merge PR")84 SUT.MergePR()85 return 286 action2adapter.func_code = aalmodel.setCodeFileLine(action2adapter.func_code, '''github.aal''', 30, "adapter of action \"i:Merge PR\"")87 action3name = "i:Close PR"88 action3type = "input"89 def action3guard():90 global state, approved, SUT91 action_name = "i:Close PR"92 input_name ="Close PR"93 action_index = 094 return state == PRState.OPEN95 action3guard.requires = []96 action3guard.func_code = aalmodel.setCodeFileLine(action3guard.func_code, '''github.aal''', 36, "guard of action \"i:Close PR\"")97 def action3body():98 global state, approved, SUT99 action_name = "i:Close PR"100 input_name ="Close PR"101 action_index = 0102 state = PRState.CLOSED103 action3body.func_code = aalmodel.setCodeFileLine(action3body.func_code, '''github.aal''', 41, "body of action \"i:Close PR\"")104 def action3adapter():105 global state, approved, SUT106 action_name = "i:Close PR"107 input_name ="Close PR"108 action_index = 0109 log("Close PR")110 SUT.ClosePR()111 return 3112 action3adapter.func_code = aalmodel.setCodeFileLine(action3adapter.func_code, '''github.aal''', 38, "adapter of action \"i:Close PR\"")113 action4name = "i:Reopen PR"114 action4type = "input"115 def action4guard():116 global state, approved, SUT117 action_name = "i:Reopen PR"118 input_name ="Reopen PR"119 action_index = 0120 return state == PRState.CLOSED121 action4guard.requires = []122 action4guard.func_code = aalmodel.setCodeFileLine(action4guard.func_code, '''github.aal''', 44, "guard of action \"i:Reopen PR\"")123 def action4body():124 global state, approved, SUT125 action_name = "i:Reopen PR"126 input_name ="Reopen PR"127 action_index = 0128 state = PRState.OPEN129 action4body.func_code = aalmodel.setCodeFileLine(action4body.func_code, '''github.aal''', 49, "body of action \"i:Reopen PR\"")130 def action4adapter():131 global state, approved, SUT132 action_name = "i:Reopen PR"133 input_name ="Reopen PR"134 action_index = 0135 log("Reopen PR")136 SUT.ReopenPR()137 return 4138 action4adapter.func_code = aalmodel.setCodeFileLine(action4adapter.func_code, '''github.aal''', 46, "adapter of action \"i:Reopen PR\"")139 action5name = "i:Change PR to Draft"140 action5type = "input"141 def action5guard():142 global state, approved, SUT143 action_name = "i:Change PR to Draft"144 input_name ="Change PR to Draft"145 action_index = 0146 return state == PRState.OPEN147 action5guard.requires = []148 action5guard.func_code = aalmodel.setCodeFileLine(action5guard.func_code, '''github.aal''', 52, "guard of action \"i:Change PR to Draft\"")149 def action5body():150 global state, approved, SUT151 action_name = "i:Change PR to Draft"152 input_name ="Change PR to Draft"153 action_index = 0154 state = PRState.DRAFT155 action5body.func_code = aalmodel.setCodeFileLine(action5body.func_code, '''github.aal''', 57, "body of action \"i:Change PR to Draft\"")156 def action5adapter():157 global state, approved, SUT158 action_name = "i:Change PR to Draft"159 input_name ="Change PR to Draft"160 action_index = 0161 log("Change PR to Draft")162 SUT.Open2Draft()163 return 5164 action5adapter.func_code = aalmodel.setCodeFileLine(action5adapter.func_code, '''github.aal''', 54, "adapter of action \"i:Change PR to Draft\"")165 action6name = "i:Change PR to Open"166 action6type = "input"167 def action6guard():168 global state, approved, SUT169 action_name = "i:Change PR to Open"170 input_name ="Change PR to Open"171 action_index = 0172 return state == PRState.DRAFT173 action6guard.requires = []174 action6guard.func_code = aalmodel.setCodeFileLine(action6guard.func_code, '''github.aal''', 60, "guard of action \"i:Change PR to Open\"")175 def action6body():176 global state, approved, SUT177 action_name = "i:Change PR to Open"178 input_name ="Change PR to Open"179 action_index = 0180 state = PRState.OPEN181 action6body.func_code = aalmodel.setCodeFileLine(action6body.func_code, '''github.aal''', 65, "body of action \"i:Change PR to Open\"")182 def action6adapter():183 global state, approved, SUT184 action_name = "i:Change PR to Open"185 input_name ="Change PR to Open"186 action_index = 0187 log("Change PR to Open")188 SUT.Draft2Open()189 return 6190 action6adapter.func_code = aalmodel.setCodeFileLine(action6adapter.func_code, '''github.aal''', 62, "adapter of action \"i:Change PR to Open\"")191 action7name = "i:Approve"192 action7type = "input"193 def action7guard():194 global state, approved, SUT195 action_name = "i:Approve"196 input_name ="Approve"197 action_index = 0198 return state == PRState.OPEN199 action7guard.requires = []200 action7guard.func_code = aalmodel.setCodeFileLine(action7guard.func_code, '''github.aal''', 68, "guard of action \"i:Approve\"")201 def action7body():202 global state, approved, SUT203 action_name = "i:Approve"204 input_name ="Approve"205 action_index = 0206 approved = min(1,approved+1)207 action7body.func_code = aalmodel.setCodeFileLine(action7body.func_code, '''github.aal''', 73, "body of action \"i:Approve\"")208 def action7adapter():209 global state, approved, SUT210 action_name = "i:Approve"211 input_name ="Approve"212 action_index = 0213 log("Approve")214 SUT.Approve()215 return 7216 action7adapter.func_code = aalmodel.setCodeFileLine(action7adapter.func_code, '''github.aal''', 70, "adapter of action \"i:Approve\"")217 action8name = "i:Change request"218 action8type = "input"219 def action8guard():220 global state, approved, SUT221 action_name = "i:Change request"222 input_name ="Change request"223 action_index = 0224 return state == PRState.OPEN225 action8guard.requires = []226 action8guard.func_code = aalmodel.setCodeFileLine(action8guard.func_code, '''github.aal''', 76, "guard of action \"i:Change request\"")227 def action8body():228 global state, approved, SUT229 action_name = "i:Change request"230 input_name ="Change request"231 action_index = 0232 approved = 0233 action8body.func_code = aalmodel.setCodeFileLine(action8body.func_code, '''github.aal''', 81, "body of action \"i:Change request\"")234 def action8adapter():235 global state, approved, SUT236 action_name = "i:Change request"237 input_name ="Change request"238 action_index = 0239 log("Change request")240 SUT.ChangeRequest()241 return 8242 action8adapter.func_code = aalmodel.setCodeFileLine(action8adapter.func_code, '''github.aal''', 78, "adapter of action \"i:Change request\"")243 tag1name = "Open"244 def tag1guard():245 global state, approved, SUT246 tag_name = "Open"247 return (state == PRState.OPEN) and (0 == approved)248 tag1guard.requires=[]249 tag1guard.func_code = aalmodel.setCodeFileLine(tag1guard.func_code, '''github.aal''', 87, "guard of tag \"Open\"")250 def tag1adapter():251 global state, approved, SUT252 tag_name = "Open"253 assert SUT.GetPRStatus() == PRState.OPEN254 tag1adapter.func_code = aalmodel.setCodeFileLine(tag1adapter.func_code, '''github.aal''', 88, "adapter of tag \"Open\"")255 tag2name = "Ready to merge"256 def tag2guard():257 global state, approved, SUT258 tag_name = "Ready to merge"259 return ((approved>0) and (state == PRState.OPEN))260 tag2guard.requires=[]261 tag2guard.func_code = aalmodel.setCodeFileLine(tag2guard.func_code, '''github.aal''', 91, "guard of tag \"Ready to merge\"")262 def tag2adapter():263 global state, approved, SUT264 tag_name = "Ready to merge"265 assert SUT.isReady2Merge()266 tag2adapter.func_code = aalmodel.setCodeFileLine(tag2adapter.func_code, '''github.aal''', 92, "adapter of tag \"Ready to merge\"")267 tag3name = "Closed"268 def tag3guard():269 global state, approved, SUT270 tag_name = "Closed"271 return state == PRState.CLOSED272 tag3guard.requires=[]273 tag3guard.func_code = aalmodel.setCodeFileLine(tag3guard.func_code, '''github.aal''', 95, "guard of tag \"Closed\"")274 def tag3adapter():275 global state, approved, SUT276 tag_name = "Closed"277 assert SUT.GetPRStatus() == PRState.CLOSED278 tag3adapter.func_code = aalmodel.setCodeFileLine(tag3adapter.func_code, '''github.aal''', 96, "adapter of tag \"Closed\"")279 tag4name = "Merged"280 def tag4guard():281 global state, approved, SUT282 tag_name = "Merged"283 return state == PRState.MERGED284 tag4guard.requires=[]285 tag4guard.func_code = aalmodel.setCodeFileLine(tag4guard.func_code, '''github.aal''', 99, "guard of tag \"Merged\"")286 def tag4adapter():287 global state, approved, SUT288 tag_name = "Merged"289 assert SUT.GetPRStatus() == PRState.MERGED290 tag4adapter.func_code = aalmodel.setCodeFileLine(tag4adapter.func_code, '''github.aal''', 100, "adapter of tag \"Merged\"")291 tag5name = "Draft"292 def tag5guard():293 global state, approved, SUT294 tag_name = "Draft"295 return state == PRState.DRAFT296 tag5guard.requires=[]297 tag5guard.func_code = aalmodel.setCodeFileLine(tag5guard.func_code, '''github.aal''', 103, "guard of tag \"Draft\"")298 def tag5adapter():299 global state, approved, SUT300 tag_name = "Draft"301 assert SUT.GetPRStatus() == PRState.DRAFT302 tag5adapter.func_code = aalmodel.setCodeFileLine(tag5adapter.func_code, '''github.aal''', 104, "adapter of tag \"Draft\"")303 def adapter_init():304 for x in _gen_github.adapter_init_list:305 ret = x()306 if not ret and ret != None:307 return ret308 return True309 def initial_state():310 for x in _gen_github.initial_state_list:311 ret = x()312 if not ret and ret != None:313 return ret314 return True315 def adapter_exit(verdict,reason):316 for x in _gen_github.adapter_exit_list:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful