Class: TestrailHelper::Client
- Inherits:
-
Object
- Object
- TestrailHelper::Client
- Defined in:
- lib/testrail_helper.rb
Instance Method Summary collapse
- #filter_by_fields_and(list, params = {}) ⇒ Object
- #filter_by_fields_or(list, params = {}) ⇒ Object
- #get_all_active_users ⇒ Object
- #get_all_test_cases_in_section(params = {}) ⇒ Object
- #get_all_users ⇒ Object
- #get_plan(plan_id) ⇒ Object
- #get_results_for_run(run_id) ⇒ Object
- #get_run_info(run_id) ⇒ Object
- #get_sections(project_id, suite_id) ⇒ Object
- #get_test_cases(params = {}) ⇒ Object
- #get_test_plan(plan_id) ⇒ Object
- #get_test_run(run_id) ⇒ Object
- #get_tests(run_id) ⇒ Object
- #get_title(case_id) ⇒ Object
- #get_user(user_id) ⇒ Object
- #get_user_by_email(email) ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
A new instance of Client.
- #update_test_case(case_id, params = {}) ⇒ Object
- #write_to_file(list, filename) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 |
# File 'lib/testrail_helper.rb', line 10 def initialize(params = {}) @client = TestRail::APIClient.new(params[:url]) @client.user = params[:username] @client.password = params[:password] @client end |
Instance Method Details
#filter_by_fields_and(list, params = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/testrail_helper.rb', line 45 def filter_by_fields_and(list, params={}) @master_list = list @temp_list = [] h = params.map h.each do |par| puts par @master_list.each do |x| puts x if x.fetch(par[0].to_s) == par[1] @temp_list << x end end @master_list = @temp_list @temp_list = [] end @master_list end |
#filter_by_fields_or(list, params = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/testrail_helper.rb', line 63 def filter_by_fields_or(list, params={}) @temp_list = list h = params.map h.each do |par| puts par @master_list.each do |x| puts x if x.fetch(par[0].to_s) == par[1] @temp_list << x end end end @master_list = @temp_list.uniq @master_list end |
#get_all_active_users ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/testrail_helper.rb', line 93 def get_all_active_users puts "getting all active_users" uri = "get_users" users = @client.send_get(uri) active_users = [] users.each do |x| active_users << x if x.fetch('is_active') == true end active_users end |
#get_all_test_cases_in_section(params = {}) ⇒ Object
17 18 19 20 21 |
# File 'lib/testrail_helper.rb', line 17 def get_all_test_cases_in_section(params={}) uri = "get_cases/#{params[:section_id]}&suite_id=#{params[:suite_id]}" uri = uri + "&priority_id=#{params[:priority]}" if params[:priority] @client.send_get(uri) end |
#get_all_users ⇒ Object
87 88 89 90 91 |
# File 'lib/testrail_helper.rb', line 87 def get_all_users puts "getting all users" uri = "get_users" @client.send_get(uri) end |
#get_plan(plan_id) ⇒ Object
40 41 42 43 |
# File 'lib/testrail_helper.rb', line 40 def get_plan(plan_id) uri = "get_plan/#{plan_id}" @client.send_get(uri) end |
#get_results_for_run(run_id) ⇒ Object
139 140 141 142 |
# File 'lib/testrail_helper.rb', line 139 def get_results_for_run(run_id) uri = "get_results_for_run/#{run_id}" @client.send_get(uri) end |
#get_run_info(run_id) ⇒ Object
30 31 32 33 |
# File 'lib/testrail_helper.rb', line 30 def get_run_info(run_id) uri = "get_run/#{run_id}" @client.send_get(uri) end |
#get_sections(project_id, suite_id) ⇒ Object
144 145 146 147 |
# File 'lib/testrail_helper.rb', line 144 def get_sections(project_id, suite_id) uri = "get_sections/#{project_id}&suite_id=#{suite_id}" @client.send_get(uri) end |
#get_test_cases(params = {}) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/testrail_helper.rb', line 23 def get_test_cases(params={}) uri = "get_cases/#{params[:project_id]}&suite_id=#{params[:project_id]}" uri = uri + "&suite_id=#{params[:suite_id]}" if params[:suite_id] uri = uri + "§ion_id=#{params[:section_id]}" if params[:section_id] @client.send_get(uri) end |
#get_test_plan(plan_id) ⇒ Object
128 129 130 131 |
# File 'lib/testrail_helper.rb', line 128 def get_test_plan(plan_id) uri = "get_plan/#{plan_id}" @client.send_get(uri) end |
#get_test_run(run_id) ⇒ Object
134 135 136 137 |
# File 'lib/testrail_helper.rb', line 134 def get_test_run(run_id) uri = "get_run/#{run_id}" @client.send_get(uri) end |
#get_tests(run_id) ⇒ Object
35 36 37 38 |
# File 'lib/testrail_helper.rb', line 35 def get_tests(run_id) uri = "get_tests/#{run_id}" @client.send_get(uri) end |
#get_title(case_id) ⇒ Object
116 117 118 119 120 |
# File 'lib/testrail_helper.rb', line 116 def get_title(case_id) puts "getting title" uri = "get_case/#{case_id}" @client.send_get(uri) end |
#get_user(user_id) ⇒ Object
104 105 106 107 108 |
# File 'lib/testrail_helper.rb', line 104 def get_user(user_id) puts "getting title" uri = "get_user/#{user_id}" @client.send_get(uri) end |
#get_user_by_email(email) ⇒ Object
110 111 112 113 114 |
# File 'lib/testrail_helper.rb', line 110 def get_user_by_email(email) puts "getting title" uri = "get_user_by_email&email=#{email}" @client.send_get(uri) end |
#update_test_case(case_id, params = {}) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/testrail_helper.rb', line 79 def update_test_case(case_id, params={}) puts "updating" params.merge({title:get_title(case_id)}) puts params uri = "update_case/#{case_id}" puts @client.send_post(uri,params) end |
#write_to_file(list, filename) ⇒ Object
122 123 124 125 126 |
# File 'lib/testrail_helper.rb', line 122 def write_to_file(list, filename) File.open(filename, "w+") do |f| list.each { |element| f.puts(element) } end end |