qalib.py

<---Back

Select Code Highlighting Style:

BRIGHT | Seashell | Darkness

Select Font Size:

Small | Normal | Large
../www/get_script_html_files/strip/qalib.py
    1 #!/usr/bin/python2
    2 
    3 #######################################
    4 #
    5 # This is module used by test tools
    6 #
    7 # Version: 1.7
    8 #
    9 #######################################
   10 
   11 #import everything from lib.py
   12 
   13 from lib import *
   14 
   15 #function to create test account
   16 
   17 def create_account():
   18 
   19     #two lists with first and last names
   20 
   21     first_name_list = [
   22     'Alex',
   23     'Amit',
   24     'Anitha',
   25     'Anna',
   26     'Brian',
   27     'Eing',
   28     'George',
   29     'Howard',
   30     'James',
   31     'Jennifer',
   32     'Linda',
   33     'Marina',
   34     'Ming',
   35     'Olga',
   36     'Prashant',
   37     'Rajiv',
   38     'Sally',
   39     'Stephen',
   40     'Ven',
   41     'Vladimir',
   42     'Zhi']
   43 
   44     last_name_list = [
   45     'Baker',
   46     'Chen',
   47     'Chopra',
   48     'Collins',
   49     'Fuente',
   50     'Gupta',
   51     'Holmes',
   52     'Huang',
   53     'Ivanoff',
   54     'Jackson',
   55     'Khan',
   56     'Lee',
   57     'Lin',
   58     'Padron',
   59     'Petroff',
   60     'Rao',
   61     'Sidoroff',
   62     'Smith',
   63     'Stuart',
   64     'Wang',
   65     'Watson']
   66 
   67 
   68     #randomly select first name and last name from lists above
   69 
   70     first_name = random.choice(first_name_list)
   71     last_name =  random.choice(last_name_list)
   72 
   73     #create an email
   74 
   75     email = first_name.lower()+'_'+last_name.lower()+'@'+str(time.time())[-6:]+'.sharelane.com'
   76 
   77     #create other values
   78 
   79     zip_code    = "94118"
   80     street      = "12 Share Lane"
   81     city        = "San Francisco"
   82     state       = "CA"
   83     country     = "USA"
   84 
   85     #run SQL
   86 
   87     sql = "insert into users (first_name,last_name,email,zip_code,password,street,city,state,country,time_created)\
   88     values ('%s','%s','%s','%s','1111','%s','%s','%s','%s',NOW())" % (first_name,last_name,email,zip_code,street,city,state,country)
   89 
   90     update(sql)
   91 
   92     #this function returns list of values
   93 
   94     main_list = []
   95     main_list.append(first_name)
   96     main_list.append(last_name)
   97     main_list.append(email)
   98     main_list.append(zip_code)
   99     main_list.append('12 Share Lane')
  100     main_list.append('San Francisco')
  101     main_list.append('CA')
  102     main_list.append('USA')
  103 
  104     return main_list
  105 
  106 #function to wrap html around pages inside Test Portal
  107 
  108 def get_qa_html(body,js=0):
  109 
  110     #JavaScript below is needed to copy specified value into clipboard
  111 
  112     if js==0:
  113 
  114         message = ''
  115 
  116     else:
  117 
  118         message = """
  119 
  120 
  121     <SCRIPT LANGUAGE="JavaScript">
  122 
  123     function ClipBoard()
  124     {
  125     holdtext.innerText = copytext.innerText;
  126     Copied = holdtext.createTextRange();
  127     Copied.execCommand("Copy");
  128     }
  129 
  130     </SCRIPT>
  131 
  132     """
  133 
  134     html = """
  135     <html>
  136 
  137         <title>Test Portal</title>
  138 
  139         <head>
  140 
  141             <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  142             <meta http-equiv="cache-control" content="no-cache">
  143             <meta http-equiv="description" content="ShareLane is practical addition to tutorial
  144     How to Become a Software Tester. See QATutor.com for details">
  145             <link rel="stylesheet" type="text/css" href="http://www.sharelane.com/styles.css" />
  146             %s
  147         </head>
  148 
  149     <body>
  150 
  151     <center>
  152 
  153     <a href="javascript: history.go(-1)" class='footer'>&lt;---Back</a> | <a href='../test_portal.html' class='footer'>Test Portal</a> | <a href="../cgi-bin/main.py" class='footer'>ShareLane homepage</a> | <a href="http://www.qatutor.com" class='footer'>QATutor.com</a>
  154 
  155     <HR>
  156 
  157     <table border=1 cellpadding=10>
  158 
  159     <tr valign='top'><td>""" % message
  160 
  161     html = html+body+"""</td>
  162 
  163     </tr></body></html>"""
  164 
  165     return html
  166