Module: Awetestlib::Regression::TestData
- Defined in:
- lib/awetestlib/regression/test_data.rb,
lib/awetestlib/regression/awetest_dsl.rb
Instance Method Summary collapse
- #get_variables ⇒ Object
- #instantiate_style_list ⇒ Object
- #load_data_variables(workbook, dbg = nil) ⇒ Object
- #load_html_validation_filters(file = @refs_spec) ⇒ Object
- #load_login_variables(workbook, enabled_only, file, key_type, scripts, dbg = nil) ⇒ Object
- #load_variables(file, key_type = :role, enabled_only = true, dbg = true, scripts = nil) ⇒ Object
- #parse_test_flag(string) ⇒ Object
Instance Method Details
#get_variables ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/awetestlib/regression/test_data.rb', line 38 def load_variables(file, key_type = :role, enabled_only = true, dbg = true, scripts = nil) mark_test_level((file, "key:'#{key_type}'")) # ok = true debug_to_log("#{__method__}: file = #{file}") debug_to_log("#{__method__}: key = #{key_type}") workbook = file =~ /\.xlsx$/ ? Roo::Excelx.new(file) : Roo::Excel.new(file) if @myName =~ /appium/i ok = script_found_in_data = script_found_in_login = true else script_found_in_data = load_data_variables(workbook, dbg) ok, script_found_in_login = load_login_variables(workbook, enabled_only, file, key_type, scripts, dbg) end unless @env_name =~ /^gen/ unless ok and script_found_in_login and script_found_in_data ok = false failed_to_log("Script found: in Login = #{script_found_in_login}; in Data = #{script_found_in_data}") end end workbook.close ok rescue failed_to_log(unable_to) end |
#instantiate_style_list ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/awetestlib/regression/awetest_dsl.rb', line 39 def instantiate_style_list @style_list = ['-webkit-app-region', '-webkit-appearance', '-webkit-background-composite', '-webkit-border-horizontal-spacing', '-webkit-border-vertical-spacing', '-webkit-box-align', '-webkit-box-decoration-break', '-webkit-box-direction', '-webkit-box-flex', '-webkit-box-flex-group', '-webkit-box-lines', '-webkit-box-ordinal-group', '-webkit-box-orient', '-webkit-box-pack', '-webkit-box-reflect', '-webkit-column-break-after', '-webkit-column-break-before', '-webkit-column-break-inside', '-webkit-column-count', '-webkit-column-gap', '-webkit-column-rule-color', '-webkit-column-rule-style', '-webkit-column-rule-width', '-webkit-column-span', '-webkit-column-width', '-webkit-font-smoothing', '-webkit-highlight', '-webkit-hyphenate-character', '-webkit-line-box-contain', '-webkit-line-break', '-webkit-line-clamp', '-webkit-locale', '-webkit-margin-after-collapse', '-webkit-margin-before-collapse', '-webkit-mask-box-image', '-webkit-mask-box-image-outset', '-webkit-mask-box-image-repeat', '-webkit-mask-box-image-slice', '-webkit-mask-box-image-source', '-webkit-mask-box-image-width', '-webkit-mask-clip', '-webkit-mask-composite', '-webkit-mask-image', '-webkit-mask-origin', '-webkit-mask-position', '-webkit-mask-repeat', '-webkit-mask-size', '-webkit-print-color-adjust', '-webkit-rtl-ordering', '-webkit-tap-highlight-color', '-webkit-text-combine', '-webkit-text-decorations-in-effect', '-webkit-text-emphasis-color', '-webkit-text-emphasis-position', '-webkit-text-emphasis-style', '-webkit-text-fill-color', '-webkit-text-orientation', '-webkit-text-security', '-webkit-text-stroke-color', '-webkit-text-stroke-width', '-webkit-user-drag', '-webkit-user-modify', '-webkit-user-select', 'align-content', 'align-items', 'align-self', 'alignment-baseline', 'animation-delay', 'animation-direction', 'animation-duration', 'animation-fill-mode', 'animation-iteration-count', 'animation-name', 'animation-play-state', 'animation-timing-function', 'backface-visibility', 'background-attachment', 'background-blend-mode', 'background-clip', 'background-color', 'background-image', 'background-origin', 'background-position', 'background-repeat', 'background-size', 'baseline-shift', 'border-bottom-color', 'border-bottom-left-radius', 'border-bottom-right-radius', 'border-bottom-style', 'border-bottom-width', 'border-collapse', '-webkit-border-image', 'border-image-outset', 'border-image-repeat', 'border-image-slice', 'border-image-source', 'border-image-width', 'border-left-color', 'border-left-style', 'border-left-width', 'border-right-color', 'border-right-style', 'border-right-width', 'border-top-color', 'border-top-left-radius', 'border-top-right-radius', 'border-top-style', 'border-top-width', 'bottom', 'box-shadow', 'box-sizing', 'buffered-rendering', 'caption-side', 'clear', 'clip', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-rendering', 'cursor', 'cx', 'cy', 'direction', 'display', 'dominant-baseline', 'empty-cells', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'flex-basis', 'flex-direction', 'flex-grow', 'flex-shrink', 'flex-wrap', 'float', 'flood-color', 'flood-opacity', 'font-family', 'font-kerning', 'font-size', 'font-stretch', 'font-style', 'font-variant', 'font-variant-ligatures', 'font-weight', 'glyph-orientation-horizontal', 'glyph-orientation-vertical', 'height', 'image-rendering', 'isolation', 'justify-content', 'left', 'letter-spacing', 'lighting-color', 'line-height', 'list-style-image', 'list-style-position', 'list-style-type', 'margin-bottom', 'margin-left', 'margin-right', 'margin-top', 'marker-end', 'marker-mid', 'marker-start', 'mask', 'mask-type', 'max-height', 'max-width', 'min-height', 'min-width', 'mix-blend-mode', 'object-fit', 'object-position', 'opacity', 'order', 'orphans', 'outline-color', 'outline-offset', 'outline-style', 'outline-width', 'overflow-wrap', 'overflow-x', 'overflow-y', 'padding-bottom', 'padding-left', 'padding-right', 'padding-top', 'page-break-after', 'page-break-before', 'page-break-inside', 'paint-order', 'perspective', 'perspective-origin', 'pointer-events', 'position', 'r', 'resize', 'right', 'rx', 'ry', 'shape-image-threshold', 'shape-margin', 'shape-outside', 'shape-rendering', 'speak', 'stop-color', 'stop-opacity', 'stroke', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke-width', 'tab-size', 'table-layout', 'text-align', 'text-anchor', 'text-decoration', 'text-indent', 'text-overflow', 'text-rendering', 'text-shadow', 'text-transform', 'top', 'touch-action', 'transform', 'transform-origin', 'transform-style', 'transition-delay', 'transition-duration', 'transition-property', 'transition-timing-function', 'unicode-bidi', 'vector-effect', 'vertical-align', 'visibility', 'white-space', 'widows', 'width', 'will-change', 'word-break', 'word-spacing', 'word-wrap', 'writing-mode', '-webkit-writing-mode', 'x', 'y', 'z-index', 'zoom'] end |
#load_data_variables(workbook, dbg = nil) ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/awetestlib/regression/test_data.rb', line 178 def load_data_variables(workbook, dbg = nil) script_found_in_data = false @var = Hash.new data_index = find_sheet_with_name(workbook, 'Data') workbook.default_sheet = workbook.sheets[data_index] var_col = 0 default_col = 2 2.upto(workbook.last_column) do |col| script_name = workbook.cell(1, col) if script_name == 'default' default_col = col end if script_name == @myName var_col = col script_found_in_data = true break end end defaults = {} 2.upto(workbook.last_row) do |line| name = workbook.cell(line, 'A') value = workbook.cell(line, default_col).to_s.strip defaults[name] = value end 2.upto(workbook.last_row) do |line| name = workbook.cell(line, 'A') value = workbook.cell(line, var_col).to_s.strip if value and value.length > 0 @var[name] = value else @var[name] = defaults[name] end end @var.keys.sort.each do |name| ("@var #{name}: '#{@var[name]}'") end if dbg script_found_in_data rescue failed_to_log(unable_to) end |
#load_html_validation_filters(file = @refs_spec) ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/awetestlib/regression/test_data.rb', line 226 def load_html_validation_filters(file = @refs_spec) sheet = 'HTML Validation Filters' workbook = file =~ /\.xlsx$/ ? Roo::Excelx.new(file) : Roo::Excel.new(file) @html_filters = Hash.new sheet_index = find_sheet_with_name(workbook, "#{sheet}") if sheet_index > -1 debug_to_log("Loading worksheet '#{sheet}'.") workbook.default_sheet = workbook.sheets[sheet_index] columns = Hash.new 1.upto(workbook.last_column) do |col| columns[workbook.cell(1, col).to_sym] = col end 2.upto(workbook.last_row) do |line| identifier = workbook.cell(line, columns[:identifier]) validator = workbook.cell(line, columns[:validator]) pattern = workbook.cell(line, columns[:pattern]) action = workbook.cell(line, columns[:action]) alt_pattern = workbook.cell(line, columns[:alt_pattern]) alt_action = workbook.cell(line, columns[:alt_action]) script = workbook.cell(line, columns[:script]) head = workbook.cell(line, columns[:head]) = workbook.cell(line, columns[:meta]) body = workbook.cell(line, columns[:body]) frame = workbook.cell(line, columns[:frame]) fragment = workbook.cell(line, columns[:fragment]) report_more = workbook.cell(line, columns[:report_more]) description = workbook.cell(line, columns[:description]) # pattern = pattern ? Regexp.escape(pattern) : nil # alt_pattern = alt_pattern ? Regexp.escape(alt_pattern) : nil @html_filters[validator] = Hash.new unless @html_filters[validator] @html_filters[validator][identifier] = { :validator => validator, :pattern => pattern, :action => action, :alt_pattern => alt_pattern, :alt_action => alt_action, :script => script, :head => head, :meta => , :body => body, :frame => frame, :fragment => fragment, :report_more => report_more, :description => description } end else failed_to_log("Worksheet '#{sheet}' not found #{file}") end @html_error_references = Hash.new sheet = 'HTML Error References' sheet_index = find_sheet_with_name(workbook, "#{sheet}") if sheet_index > -1 debug_to_log("Loading worksheet '#{sheet}'.") workbook.default_sheet = workbook.sheets[sheet_index] columns = Hash.new 1.upto(workbook.last_column) do |col| columns[workbook.cell(1, col).to_sym] = col end 2.upto(workbook.last_row) do |line| validator = workbook.cell(line, columns[:validator]) pattern = workbook.cell(line, columns[:pattern]) reference = workbook.cell(line, columns[:reference]) component = workbook.cell(line, columns[:component]) alm_df = workbook.cell(line, columns[:alm_df]) jira_ref = workbook.cell(line, columns[:jira_ref]) description = workbook.cell(line, columns[:description]) # pattern = pattern ? Regexp.escape(pattern) : nil @html_error_references[pattern] = { :validator => validator, :reference => reference, :component => component, :alm_df => alm_df, :jira_ref => jira_ref, :description => description } end else failed_to_log("Worksheet '#{sheet}' not found #{file}") end workbook.close [@html_filters, @html_error_references] rescue failed_to_log(unable_to) end |
#load_login_variables(workbook, enabled_only, file, key_type, scripts, dbg = nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/awetestlib/regression/test_data.rb', line 40 def load_login_variables(workbook, enabled_only, file, key_type, scripts, dbg = nil) ok = true script_found_in_login = false @login = Hash.new enabled_cnt = 0 script_col = 0 role_col = 0 userid_col = 0 company_col = 0 password_col = 0 url_col = 0 env_col = 0 name_col = 0 appid_col = 0 ref_col = 0 node_col = 0 login_index = find_sheet_with_name(workbook, 'Login') if login_index and login_index >= 0 workbook.default_sheet = workbook.sheets[login_index] 1.upto(workbook.last_column) do |col| column_name = workbook.cell(1, col).downcase case column_name when @myName.downcase script_col = col script_found_in_login = true if scripts.is_a?(Array) scripts << column_name else break end when 'role' role_col = col when 'userid', 'user_id' userid_col = col when 'companyid', 'company_id' company_col = col when 'password' password_col = col when 'url' url_col = col when 'environment' env_col = col when /reference/i ref_col = col when 'nodename' node_col = col when 'name' name_col = col when 'appid', 'app_id' appid_col = col else scripts << column_name if scripts.is_a?(Array) end end 2.upto(workbook.last_row) do |line| role = workbook.cell(line, role_col) userid = workbook.cell(line, userid_col) password = workbook.cell(line, password_col) url = workbook.cell(line, url_col) env = workbook.cell(line, env_col) username = workbook.cell(line, name_col) nodename = workbook.cell(line, node_col) companyid = workbook.cell(line, company_col) appid = workbook.cell(line, appid_col) enabled = workbook.cell(line, script_col).to_s refs = workbook.cell(line, ref_col) case key_type when :id, :userid key = userid when :environment key = env when :role key = role else key = userid end if enabled_only and enabled.length == 0 next end @login[key] = Hash.new @login[key]['role'] = role @login[key]['userid'] = userid @login[key]['companyid'] = companyid @login[key]['password'] = password @login[key]['url'] = url @login[key]['name'] = username @login[key]['nodename'] = nodename @login[key]['enabled'] = enabled @login[key]['environment'] = env @login[key]['appid'] = appid @login[key]['references'] = refs if enabled =~ /^y$/i case key_type when :environment case env when /^gen/i enabled_cnt += 1 else enabled_cnt += 1 if @env_name =~ /#{env}/ end else enabled_cnt += 1 end end end @login.keys.sort.each do |key| ("@login (by #{key_type}): #{key}='#{@login[key].to_yaml}'") end if dbg else fail "'Login' worksheet not found in #{file}" end unless enabled_cnt > 0 ok = false case key_type when :environment err_msg = "No enabled 'Login' entries for rows matching :#{key_type} => '#{@env_name}'" else err_msg = "No enabled 'Login' entries for rows matching :#{key_type}" end fail err_msg end return ok, script_found_in_login rescue failed_to_log(unable_to) end |
#load_variables(file, key_type = :role, enabled_only = true, dbg = true, scripts = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/awetestlib/regression/test_data.rb', line 7 def load_variables(file, key_type = :role, enabled_only = true, dbg = true, scripts = nil) mark_test_level((file, "key:'#{key_type}'")) # ok = true debug_to_log("#{__method__}: file = #{file}") debug_to_log("#{__method__}: key = #{key_type}") workbook = file =~ /\.xlsx$/ ? Roo::Excelx.new(file) : Roo::Excel.new(file) if @myName =~ /appium/i ok = script_found_in_data = script_found_in_login = true else script_found_in_data = load_data_variables(workbook, dbg) ok, script_found_in_login = load_login_variables(workbook, enabled_only, file, key_type, scripts, dbg) end unless @env_name =~ /^gen/ unless ok and script_found_in_login and script_found_in_data ok = false failed_to_log("Script found: in Login = #{script_found_in_login}; in Data = #{script_found_in_data}") end end workbook.close ok rescue failed_to_log(unable_to) end |
#parse_test_flag(string) ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/awetestlib/regression/test_data.rb', line 326 def parse_test_flag(string) test = false refs = nil arr = string.is_a?(Array) ? string : string.to_s.split(/,\s*/) ref_arr = [] arr.each { |r| ref_arr << format_reference(r) } if string if string == true or string == false test = string else if string.length > 0 unless string =~ /^no$|^false$/i test = true unless string =~ /^yes$|^true$/i refs = format_refs(string) end end end end end [test, refs, ref_arr] rescue failed_to_log(unable_to) end |