WAR-1708 Integrate Selenium test into travis by kaheichan · Pull Request #356 · warriorframework/warriorframework
Expand Up
@@ -10,13 +10,14 @@
See the License for the specific language governing permissions and
limitations under the License.
'''
import datetime from Framework import Utils from Framework.Utils import data_Utils, file_Utils, datetime_utils, config_Utils import os import time from Framework import Utils from Framework.Utils import data_Utils, file_Utils, datetime_utils from Framework.Utils.testcase_Utils import pNote
class CIregressionActions(object): """ This class contains keywords that are used in warrior regression test Expand Down Expand Up @@ -59,7 +60,7 @@ def once_per_tc_with_system_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per tese case with system name given" pNote(wdesc) key = 'once_per_tc_with_system_name_given_'+str(step_num) Expand All @@ -75,7 +76,7 @@ def once_per_tc_with_no_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per testcase with system name not given" pNote(wdesc) key = 'once_per_tc_with_no_name_given_'+str(step_num) Expand All @@ -91,7 +92,7 @@ def once_per_tc_with_error(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per testcase with error" pNote(wdesc) key = 'once_per_tc_with_error_'+str(step_num) Expand All @@ -108,7 +109,7 @@ def standard_with_system_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Standard with system name given" pNote(wdesc) key = 'standard_with_system_name_given_'+str(step_num) Expand All @@ -124,7 +125,7 @@ def standard_with_system_name_not_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Standard with system name not given" pNote(wdesc) key = 'standard_with_system_name_not_given_'+str(step_num) Expand Down Expand Up @@ -195,11 +196,11 @@ def end_of_tc_with_error(self, system_name, step_num):
def compare_hybrid_tc_result(self,input_file): """ It takes the input file path which is the expected result and compares with the log file and It takes the input file path which is the expected result and compares with the log file and returns True if both matches else False and prints the difference to console.
Arguments: input_file: It takes expected result file path as input input_file: It takes expected result file path as input """ wdesc = "Compares the test case result file with expected result file" pNote(wdesc) Expand Down Expand Up @@ -330,196 +331,6 @@ def delete_tmp_dir(self): path = data_Utils.get_object_from_datarepository("parallel_exec_tmp_dir") return file_Utils.delFolder(path)
def check_kw_arg_type_prefix(self, str_value, int_value, float_value, bool_value, list_value, tuple_value, dict_value, file_value): """This keyword is intended to test the type prefix for keyword arguments when an argument name has a type_ prefix, the variable type will become the type specified in the type_ prefix :Argument: 1. str_value - expected to be string 2. int_value - expected to be int 3. float_value - expected to be float 4. bool_value - expected to be bool 5. list_value - expected to be list 6. tuple_value - expected to be tuple 7. dict_value - expected to be dict 8. file_value - expected to be file """ file_contents = "Checking file datatype in wtags" status = True err_msg = "{} is not an {} value but of type {}" if type(str_value) is not str: # this block checks if str_value is string type pNote(err_msg.format(str_value, "str", type(str_value)), "error") status = False if type(int_value) is not int: # this block checks if int_value is int type pNote(err_msg.format(int_value, "int", type(int_value)), "error") status = False if type(float_value) is not float: # this block checks if float_value is float type pNote(err_msg.format(float_value, "float", type(float_value)), "error") status = False if type(bool_value) is not bool: # this block checks if bool_value is bool type pNote(err_msg.format(bool_value, "bool", type(bool_value)), "error") status = False if type(list_value) is not list: # this block checks if list_value is list type pNote(err_msg.format(list_value, "list", type(list_value)), "error") status = False if type(tuple_value) is not tuple: # this block checks if tuple_value is tuple type pNote(err_msg.format(tuple_value, "tuple", type(tuple_value)), "error") status = False if type(dict_value) is not dict: # this block checks if dict_value is dict type pNote(err_msg.format(dict_value, "dict", type(dict_value)), "error") status = False if type(file_value) is not file: # this block checks if file_value is file type pNote(err_msg.format(file_value, "file", type(file_value)), "error") status = False else: actual_contents = file_value.read().strip() if actual_contents != file_contents: # this block checks if the contents of file type variable is expected pNote("contents of the file {} is <<{}>> which does not match expected" " <<{}>>".format(file_value, actual_contents, file_contents), "error") status = False return status
def check_values_from_datafile(self, system_name, strvar, langs, states, currencys, ramspace, configfile, intvar, anotherfile): """Verify the datatype of the value read from the datafile using either the tag or wtag feature :Argument: 1. system_name = system name in the datafile 2. strvar = string variable 3. langs = list variable (should get from data file using wtag) 4. states = tuple variable 5. currencys = dict variable 6. ramspace = boolean variable 7. configfile = file variable 8. intvar = int variable 9. anotherfile = file variable """ def check_type(var, varname, datatype): """check that vars are of correct datatype """ vartype = type(var) status = True if vartype is not datatype: pNote('{} is expected to be {} type, but found to be of ' '{} type'.format(varname, datatype, vartype), "error") status = False return status status = True datafile = Utils.config_Utils.datafile tc_filepath = os.path.dirname(data_Utils.get_object_from_datarepository( 'wt_testcase_filepath')) # this block checks if strvar is string type status = check_type(strvar, "strvar", str) and status # this block checks if langs is list type status = check_type(langs, "langs", list) and status # this block checks if states is tuple type status = check_type(states, "states", tuple) and status # this block checks if currencys is dict type status = check_type(currencys, "currencys", dict) and status # this block checks if ramspace is bool type status = check_type(ramspace, "ramspace", bool) and status file_err = '{} is not a file, please check' try: # check if tag is present and its functionality is not broken if anotherfile.startswith('tag'): anotherfile = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, anotherfile) # this checks if configfile and anotherfile are valid files # by getting the absolute path of the file if not os.path.isabs(configfile): configfile = file_Utils.getAbsPath(configfile, tc_filepath) if not os.path.isabs(anotherfile): anotherfile = file_Utils.getAbsPath(anotherfile, tc_filepath) if not os.path.isfile(configfile): pNote(file_err.format(configfile), "error") if not os.path.isfile(anotherfile): pNote(file_err.format(anotherfile), "error") except AttributeError: pNote('configfile and anotherfile are expected to be files', "error") pNote('type of configfile is {}'.format(type(configfile)), "error") pNote('type of anotherfile is {}'.format(type(anotherfile)), "error") status = False if type(intvar) is str and intvar.startswith('tag'): intvar = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, intvar) else: status = check_type(intvar, "intvar", int) and status return status
def check_opt_values_from_datafile(self, langs=['Sanskrit', 'Tamil'], strvar="I am a default variable", states="wtag=states", system_name="sys_wtag", currencys={'USA': 'USD'}, ramspace=False, configfile="../../config_files/check_file_type", intvar=496): """Verify the datatype of the value read from the datafile using either the tag or wtag feature :Argument: 1. system_name = system name in the datafile 2. strvar = string variable 3. langs = list variable (should get from data file using wtag) 4. states = tuple variable 5. currencys = dict variable 6. ramspace = boolean variable 7. configfile = file variable 8. intvar = int variable """ def check_type(var, varname, datatype): """check that vars are of correct datatype """ vartype = type(var) status = True if vartype is not datatype: pNote('{} is expected to be {} type, but found to be of ' '{} type'.format(varname, datatype, vartype), "error") status = False return status status = True datafile = Utils.config_Utils.datafile tc_filepath = os.path.dirname(data_Utils.get_object_from_datarepository( 'wt_testcase_filepath')) # this block checks if strvar is string type status = check_type(strvar, "strvar", str) and status # this block checks if langs is list type status = check_type(langs, "langs", list) and status # this block checks if states is tuple type status = check_type(states, "states", tuple) and status # this block checks if currencys is dict type status = check_type(currencys, "currencys", dict) and status # this block checks if ramspace is bool type status = check_type(ramspace, "ramspace", bool) and status file_err = '{} is not a file, please check' try: # this checks if configfile and anotherfile are valid files # by getting the absolute path of the file if not os.path.isabs(configfile): configfile = file_Utils.getAbsPath(configfile, tc_filepath) if not os.path.isfile(configfile): pNote(file_err.format(configfile), "error") except AttributeError: pNote('configfile and anotherfile are expected to be files', "error") pNote('type of configfile is {}'.format(type(configfile)), "error") status = False if type(intvar) is str and intvar.startswith('tag'): intvar = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, intvar) else: status = check_type(intvar, "intvar", int) and status return status
def generate_timestamp_delta(self, stored_delta_key, timestamp_key, desired_status): """ test keyword created for runmode_timer Expand Down
import datetime from Framework import Utils from Framework.Utils import data_Utils, file_Utils, datetime_utils, config_Utils import os import time from Framework import Utils from Framework.Utils import data_Utils, file_Utils, datetime_utils from Framework.Utils.testcase_Utils import pNote
class CIregressionActions(object): """ This class contains keywords that are used in warrior regression test Expand Down Expand Up @@ -59,7 +60,7 @@ def once_per_tc_with_system_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per tese case with system name given" pNote(wdesc) key = 'once_per_tc_with_system_name_given_'+str(step_num) Expand All @@ -75,7 +76,7 @@ def once_per_tc_with_no_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per testcase with system name not given" pNote(wdesc) key = 'once_per_tc_with_no_name_given_'+str(step_num) Expand All @@ -91,7 +92,7 @@ def once_per_tc_with_error(self, system_name, step_num): Returns: Returns True """
wdesc = "Once per testcase with error" pNote(wdesc) key = 'once_per_tc_with_error_'+str(step_num) Expand All @@ -108,7 +109,7 @@ def standard_with_system_name_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Standard with system name given" pNote(wdesc) key = 'standard_with_system_name_given_'+str(step_num) Expand All @@ -124,7 +125,7 @@ def standard_with_system_name_not_given(self, system_name, step_num): Returns: Returns True """
wdesc = "Standard with system name not given" pNote(wdesc) key = 'standard_with_system_name_not_given_'+str(step_num) Expand Down Expand Up @@ -195,11 +196,11 @@ def end_of_tc_with_error(self, system_name, step_num):
def compare_hybrid_tc_result(self,input_file): """ It takes the input file path which is the expected result and compares with the log file and It takes the input file path which is the expected result and compares with the log file and returns True if both matches else False and prints the difference to console.
Arguments: input_file: It takes expected result file path as input input_file: It takes expected result file path as input """ wdesc = "Compares the test case result file with expected result file" pNote(wdesc) Expand Down Expand Up @@ -330,196 +331,6 @@ def delete_tmp_dir(self): path = data_Utils.get_object_from_datarepository("parallel_exec_tmp_dir") return file_Utils.delFolder(path)
def check_kw_arg_type_prefix(self, str_value, int_value, float_value, bool_value, list_value, tuple_value, dict_value, file_value): """This keyword is intended to test the type prefix for keyword arguments when an argument name has a type_ prefix, the variable type will become the type specified in the type_ prefix :Argument: 1. str_value - expected to be string 2. int_value - expected to be int 3. float_value - expected to be float 4. bool_value - expected to be bool 5. list_value - expected to be list 6. tuple_value - expected to be tuple 7. dict_value - expected to be dict 8. file_value - expected to be file """ file_contents = "Checking file datatype in wtags" status = True err_msg = "{} is not an {} value but of type {}" if type(str_value) is not str: # this block checks if str_value is string type pNote(err_msg.format(str_value, "str", type(str_value)), "error") status = False if type(int_value) is not int: # this block checks if int_value is int type pNote(err_msg.format(int_value, "int", type(int_value)), "error") status = False if type(float_value) is not float: # this block checks if float_value is float type pNote(err_msg.format(float_value, "float", type(float_value)), "error") status = False if type(bool_value) is not bool: # this block checks if bool_value is bool type pNote(err_msg.format(bool_value, "bool", type(bool_value)), "error") status = False if type(list_value) is not list: # this block checks if list_value is list type pNote(err_msg.format(list_value, "list", type(list_value)), "error") status = False if type(tuple_value) is not tuple: # this block checks if tuple_value is tuple type pNote(err_msg.format(tuple_value, "tuple", type(tuple_value)), "error") status = False if type(dict_value) is not dict: # this block checks if dict_value is dict type pNote(err_msg.format(dict_value, "dict", type(dict_value)), "error") status = False if type(file_value) is not file: # this block checks if file_value is file type pNote(err_msg.format(file_value, "file", type(file_value)), "error") status = False else: actual_contents = file_value.read().strip() if actual_contents != file_contents: # this block checks if the contents of file type variable is expected pNote("contents of the file {} is <<{}>> which does not match expected" " <<{}>>".format(file_value, actual_contents, file_contents), "error") status = False return status
def check_values_from_datafile(self, system_name, strvar, langs, states, currencys, ramspace, configfile, intvar, anotherfile): """Verify the datatype of the value read from the datafile using either the tag or wtag feature :Argument: 1. system_name = system name in the datafile 2. strvar = string variable 3. langs = list variable (should get from data file using wtag) 4. states = tuple variable 5. currencys = dict variable 6. ramspace = boolean variable 7. configfile = file variable 8. intvar = int variable 9. anotherfile = file variable """ def check_type(var, varname, datatype): """check that vars are of correct datatype """ vartype = type(var) status = True if vartype is not datatype: pNote('{} is expected to be {} type, but found to be of ' '{} type'.format(varname, datatype, vartype), "error") status = False return status status = True datafile = Utils.config_Utils.datafile tc_filepath = os.path.dirname(data_Utils.get_object_from_datarepository( 'wt_testcase_filepath')) # this block checks if strvar is string type status = check_type(strvar, "strvar", str) and status # this block checks if langs is list type status = check_type(langs, "langs", list) and status # this block checks if states is tuple type status = check_type(states, "states", tuple) and status # this block checks if currencys is dict type status = check_type(currencys, "currencys", dict) and status # this block checks if ramspace is bool type status = check_type(ramspace, "ramspace", bool) and status file_err = '{} is not a file, please check' try: # check if tag is present and its functionality is not broken if anotherfile.startswith('tag'): anotherfile = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, anotherfile) # this checks if configfile and anotherfile are valid files # by getting the absolute path of the file if not os.path.isabs(configfile): configfile = file_Utils.getAbsPath(configfile, tc_filepath) if not os.path.isabs(anotherfile): anotherfile = file_Utils.getAbsPath(anotherfile, tc_filepath) if not os.path.isfile(configfile): pNote(file_err.format(configfile), "error") if not os.path.isfile(anotherfile): pNote(file_err.format(anotherfile), "error") except AttributeError: pNote('configfile and anotherfile are expected to be files', "error") pNote('type of configfile is {}'.format(type(configfile)), "error") pNote('type of anotherfile is {}'.format(type(anotherfile)), "error") status = False if type(intvar) is str and intvar.startswith('tag'): intvar = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, intvar) else: status = check_type(intvar, "intvar", int) and status return status
def check_opt_values_from_datafile(self, langs=['Sanskrit', 'Tamil'], strvar="I am a default variable", states="wtag=states", system_name="sys_wtag", currencys={'USA': 'USD'}, ramspace=False, configfile="../../config_files/check_file_type", intvar=496): """Verify the datatype of the value read from the datafile using either the tag or wtag feature :Argument: 1. system_name = system name in the datafile 2. strvar = string variable 3. langs = list variable (should get from data file using wtag) 4. states = tuple variable 5. currencys = dict variable 6. ramspace = boolean variable 7. configfile = file variable 8. intvar = int variable """ def check_type(var, varname, datatype): """check that vars are of correct datatype """ vartype = type(var) status = True if vartype is not datatype: pNote('{} is expected to be {} type, but found to be of ' '{} type'.format(varname, datatype, vartype), "error") status = False return status status = True datafile = Utils.config_Utils.datafile tc_filepath = os.path.dirname(data_Utils.get_object_from_datarepository( 'wt_testcase_filepath')) # this block checks if strvar is string type status = check_type(strvar, "strvar", str) and status # this block checks if langs is list type status = check_type(langs, "langs", list) and status # this block checks if states is tuple type status = check_type(states, "states", tuple) and status # this block checks if currencys is dict type status = check_type(currencys, "currencys", dict) and status # this block checks if ramspace is bool type status = check_type(ramspace, "ramspace", bool) and status file_err = '{} is not a file, please check' try: # this checks if configfile and anotherfile are valid files # by getting the absolute path of the file if not os.path.isabs(configfile): configfile = file_Utils.getAbsPath(configfile, tc_filepath) if not os.path.isfile(configfile): pNote(file_err.format(configfile), "error") except AttributeError: pNote('configfile and anotherfile are expected to be files', "error") pNote('type of configfile is {}'.format(type(configfile)), "error") status = False if type(intvar) is str and intvar.startswith('tag'): intvar = data_Utils.resolve_argument_value_to_get_tag_value( datafile, system_name, intvar) else: status = check_type(intvar, "intvar", int) and status return status
def generate_timestamp_delta(self, stored_delta_key, timestamp_key, desired_status): """ test keyword created for runmode_timer Expand Down