Module: OnlyofficeTestrailWrapper::TestrailProjectRunMethods
- Extended by:
- Gem::Deprecate
- Included in:
- TestrailProject
- Defined in:
- lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb
Overview
Methods to perform operations on Runs
Instance Method Summary collapse
- #create_new_run(name, suite_id, description = '') ⇒ Object
- #get_run_by_id(id) ⇒ Object
-
#get_run_by_name(name) ⇒ TestRunTestRail
Get Test Run by it’s name.
-
#get_runs(filters = {}) ⇒ Array<Hash>
Get all test runs of project.
- #init_run_by_name(name, suite_id = nil) ⇒ Object
-
#runs(filters = {}) ⇒ Array<TestrailRun>
Get all test runs of project as objects.
-
#runs_older_than_days(days_old, not_closed: true) ⇒ Array<TestrailRun>
Get list of runs which older than several days.
- #test_run(name_or_id) ⇒ Object
Instance Method Details
#create_new_run(name, suite_id, description = '') ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 61 def create_new_run(name, suite_id, description = '') new_run = TestrailRun.new.init_from_hash(Testrail2.http_post("index.php?/api/v2/add_run/#{@id}", name: StringHelper.warnstrip!(name), description: description, suite_id: suite_id)) OnlyofficeLoggerHelper.log "Created new run: #{new_run.name}" new_run.instance_variable_set(:@project, self) @runs_names[new_run.name] = new_run.id new_run end |
#get_run_by_id(id) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 48 def get_run_by_id(id) run = TestrailRun.new.init_from_hash(Testrail2.http_get("index.php?/api/v2/get_run/#{id}")) OnlyofficeLoggerHelper.log("Initialized run: #{run.name}") run.instance_variable_set(:@project, self) run end |
#get_run_by_name(name) ⇒ TestRunTestRail
Get Test Run by it’s name
43 44 45 46 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 43 def get_run_by_name(name) get_runs if @runs_names.empty? @runs_names[StringHelper.warnstrip!(name)].nil? ? nil : get_run_by_id(@runs_names[name]) end |
#get_runs(filters = {}) ⇒ Array<Hash>
Get all test runs of project
19 20 21 22 23 24 25 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 19 def get_runs(filters = {}) get_url = "index.php?/api/v2/get_runs/#{@id}" filters.each { |key, value| get_url += "&#{key}=#{value}" } runs = Testrail2.http_get(get_url) @runs_names = name_id_pairs(runs) if @runs_names.empty? runs end |
#init_run_by_name(name, suite_id = nil) ⇒ Object
55 56 57 58 59 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 55 def init_run_by_name(name, suite_id = nil) found_run = get_run_by_name name suite_id = get_suite_by_name(name).id if suite_id.nil? found_run.nil? ? create_new_run(name, suite_id) : found_run end |
#runs(filters = {}) ⇒ Array<TestrailRun>
Get all test runs of project as objects
30 31 32 33 34 35 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 30 def runs(filters = {}) get_url = "index.php?/api/v2/get_runs/#{@id}" filters.each { |key, value| get_url += "&#{key}=#{value}" } runs = Testrail2.http_get(get_url) runs.map { |suite| TestrailRun.new.init_from_hash(suite) } end |
#runs_older_than_days(days_old, not_closed: true) ⇒ Array<TestrailRun>
Get list of runs which older than several days
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 76 def runs_older_than_days(days_old, not_closed: true) closed_flag_digit = not_closed ? 0 : 1 OnlyofficeLoggerHelper.log("Getting runs for #{@name}, days old: #{days_old}") = Date.today.prev_day(days_old).to_time.to_i get_runs(created_before: , is_completed: closed_flag_digit).map do |r| TestrailRun.new(r['name'], r['description'], r['suite_id'], r['id'], is_completed: r['is_completed']) end end |
#test_run(name_or_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/onlyoffice_testrail_wrapper/testrail_project/testrail_project_runs_methods.rb', line 6 def test_run(name_or_id) case name_or_id.class.to_s when 'Fixnum' get_run_by_id name_or_id when 'String' init_run_by_name name_or_id else raise 'Wrong argument. Must be name [String] or id [Integer]' end end |