testrail_api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb52cfc594ad739c4d1dd01c7d64c946c79f0f9d
4
- data.tar.gz: 897f5941ce0664f700278dfeb821f465a81b752d
3
+ metadata.gz: 56946d133f1eaa0e9b2e342c28e6f3b910379b7c
4
+ data.tar.gz: 1c0a33fa6e867ed4f116a164c8b8d9b67425eb64
5
5
  SHA512:
6
- metadata.gz: a76bfba7357235af742b1d49bb66e448013cf4026af84a97c09b89cab2b95e4a8687e8d4373a0dafb873c39ceecb3fe768267557d8af81b60ebc829967c645c6
7
- data.tar.gz: 63da2d010b5e42575b8e179f8f86981c317dc644bca8f5a69e3e8862b68dc59554117f3e2f44e585eab2458562f47d22ef06d13fc7b7b8f6fa54f62b9fbd7c05
6
+ metadata.gz: 5876e9354a0ec6abbc0cdfdbf443f9a7f1ac494f1c7cb9b37a10cca36f4f06d1d764e4c3333cc126978ca5570ba2ede2e300dbd31d623ba91ad687dab2a34619
7
+ data.tar.gz: 14dd134a9e8dbcd10bf7db8abe11d147be13fd93ac8992ff4ff0e9e568738269123bef79e0dac6bd987b1e28d8c4c5d27da40040fbb44b90a38c4e9adaef81d3
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Testrail API v2 client
2
+
3
+ This is client for TestRail API v2. See official [documentation](http://docs.gurock.com/testrail-api2/start) for
4
+ reference.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'testrail_api'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install testrail_api
21
+
22
+ ## Usage
23
+
24
+ ```ruby
25
+ client = TestRail::Client.new('example.testrail.com', 'admin@example.com', 'pass')
26
+ puts client.projects
27
+ ```
28
+
29
+ ## Development
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kirillzh/testrail_api. This project is
36
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1 @@
1
+ require 'testrail_api/client'
@@ -0,0 +1,71 @@
1
+ require 'testrail_api/endpoints'
2
+ require 'testrail_api/version'
3
+
4
+ require 'typhoeus'
5
+ require 'json'
6
+
7
+ module TestRail
8
+ class Client
9
+ attr_accessor :server
10
+ attr_accessor :username, :password
11
+ attr_accessor :verbose
12
+
13
+ # @param server [String] TestRail server host
14
+ # @param email [String] TestRail email
15
+ # @param password [String] TestRail password or API key
16
+ # @param opts [Hash] Optional parameters
17
+ # @option opts [Boolean] :verbose Print libcurl debug output to the console (STDERR) if true (default : false)
18
+ # @option opts [Boolean] :secure Use HTTPS if true (default: true)
19
+ def initialize(server, email, password, opts = {})
20
+ # required
21
+ @server = server
22
+ @username = email
23
+ @password = password
24
+
25
+ # optional
26
+ @verbose = opts.fetch(:verbose, false)
27
+ @secure = opts.fetch(:secure, true)
28
+ Typhoeus::Config.verbose = verbose
29
+ end
30
+
31
+ def scheme
32
+ @scheme ||= @secure ? 'https' : 'http'
33
+ end
34
+
35
+ def api_endpoint
36
+ @api_endpoint ||= File.join("#{scheme}://#{@server}", 'index.php?api/v2') if @server
37
+ end
38
+
39
+ def user_agent
40
+ @user_agent ||= "TestRail API v2 Gem #{VERSION}"
41
+ end
42
+
43
+ def default_headers
44
+ @default_headers ||= {
45
+ 'Accept' => 'application/json',
46
+ 'Content-Type' => 'application/json',
47
+ 'User-Agent' => user_agent
48
+ }
49
+ end
50
+
51
+ def get(path, opts = {})
52
+ request(:get, path, opts)
53
+ end
54
+
55
+ def post(path, opts = {})
56
+ request(:post, path, opts)
57
+ end
58
+
59
+ def request(method, path, opts = {})
60
+ body = Typhoeus::Request.new(
61
+ File.join(api_endpoint, path),
62
+ { method: method,
63
+ headers: default_headers,
64
+ userpwd: "#{@username}:#{@password}" }.merge(opts)
65
+ ).run.body
66
+ JSON.parse(body)
67
+ rescue JSON::ParserError
68
+ body
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,17 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Case Fields API
4
+ # Use the following API methods to request details about custom fields for test cases.
5
+
6
+ # @see http://docs.gurock.com/testrail-api2/reference-cases-fields
7
+
8
+ #
9
+ # Returns a list of available test case custom fields.
10
+ #
11
+ # @return [Array<Hash>] a list of available test case custom fields
12
+ #
13
+ def case_fields
14
+ get('get_case_fields')
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Case Types API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-cases-types
6
+ def case_types
7
+ get('get_case_types')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,78 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Cases API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-cases
6
+ #
7
+ # Returns an existing test case
8
+ #
9
+ # @param [Integer, String] case_id The ID of the test case
10
+ # @return an existing test case
11
+ # @see http://docs.gurock.com/testrail-api2/reference-cases#get_case
12
+ def case(case_id)
13
+ get("get_case/#{case_id}")
14
+ end
15
+
16
+ #
17
+ # Returns a list of test cases for a test suite or specific section in a test suite.
18
+ #
19
+ # @param [Integer, String] project_id The ID of the project the test run should be added to
20
+ # @param [Integer, String] suite_id The ID of the test suite (optional if the project is operating in single suite mode)
21
+ # @param [Integer, String] section_id The ID of the section (optional)
22
+ # @param filters [Hash]: A customizable set of filters
23
+ # @option filters [Integer] :created_after Only return test cases created after this date (as UNIX timestamp).
24
+ # @option filters [Integer] :created_before Only return test cases created before this date (as UNIX timestamp).
25
+ # @option filters [Array<Integer>] :created_by A comma-separated list of creators (user IDs) to filter by.
26
+ # @option filters [Array<Integer>] :milestone_id A comma-separated list of milestone IDs to filter by (not available if the milestone field is disabled for the project).
27
+ # @option filters [Array<Integer>] :priority_id A comma-separated list of priority IDs to filter by.
28
+ # @option filters [Array<Integer>] :type_id A comma-separated list of case type IDs to filter by.
29
+ # @option filters [Integer] :updated_after Only return test cases updated after this date (as UNIX timestamp).
30
+ # @option filters [Integer] :updated_before Only return test cases updated before this date (as UNIX timestamp).
31
+ # @option filters [Array<Integer>] :updated_by A comma-separated list of users who updated test cases to filter by.
32
+ # @return a list of test cases for a test suite or specific section in a test suite. The response includes an array of test cases. Each test case in this list follows the same format as TestRail#Client#get_case
33
+ # @see http://docs.gurock.com/testrail-api2/reference-cases#get_cases
34
+ def cases(project_id, suite_id, section_id = '', filters = {})
35
+ get("get_cases/#{project_id}&suite_id=#{suite_id}&section_id=#{section_id}", filters)
36
+ end
37
+
38
+ #
39
+ # Creates a new test case.
40
+ #
41
+ # @param [Integer, String] section_id The ID of the section the test case should be added to
42
+ # @param payload [Hash]: A customizable payload
43
+ # @option payload [String] :title The title of the test case (required)
44
+ # @option payload [Integer] :type_id The ID of the case type
45
+ # @option payload [Integer] :priority_id The ID of the case priority
46
+ # @option payload [String] :estimate The estimate, e.g. "30s" or "1m 45s"
47
+ # @option payload [Integer] :milestone_id The ID of the milestone to link to the test case
48
+ # @option payload [String] :refs A comma-separated list of references/requirements
49
+ # TODO: finish docs
50
+ # @return
51
+ # @see http://docs.gurock.com/testrail-api2/reference-cases#add_case
52
+ def add_case(section_id, payload)
53
+ post("get_case/#{section_id}", payload)
54
+ end
55
+
56
+ #
57
+ # Returns an existing test case by its name.
58
+ # :case_name The ID of the test case if number provided
59
+ #
60
+ def case_by_name(_case_name)
61
+ # TODO: implement get_case_by_name
62
+ end
63
+
64
+ # Custom method
65
+ # TODO: finish docs
66
+ def cases_ids(project_id, suite_id, section_id = '')
67
+ cases(project_id, suite_id, section_id).map { |x| x['id'] }
68
+ end
69
+
70
+ def update_case(_case_id, _payload)
71
+ # TODO: finish
72
+ end
73
+
74
+ def delete_case(_case_id)
75
+ # TODO: finish
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,8 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Milestones API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-milestones
6
+ # TODO: implement
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Plans API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-plans
6
+ # TODO: implement
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Priorities API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-priorities
6
+ #
7
+ # Returns a list of available priorities
8
+ #
9
+ def priorities
10
+ get('get_priorities')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,35 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Projects API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-projects
6
+ #
7
+ # Returns the list of available projects.
8
+ #
9
+ def projects
10
+ get('get_projects')
11
+ end
12
+
13
+ #
14
+ # Returns an existing project by its ID.
15
+ #
16
+ # :project_id The ID of the project
17
+ #
18
+ def project(project_id)
19
+ get("get_project/#{project_id}")
20
+ end
21
+
22
+ #
23
+ # Returns an existing project by its name.
24
+ #
25
+ # :project_name The name of the project
26
+ #
27
+ def project_by_name(project_name, ignore_case = true)
28
+ if ignore_case
29
+ projects.find { |project| project['name'].casecmp(project_name) == 0 }
30
+ else
31
+ projects.find { |project| project['name'] == project_name }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,8 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Result Fields API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-results-fields
6
+ # TODO: implement
7
+ end
8
+ end
@@ -0,0 +1,108 @@
1
+ # TODO: finish docs
2
+ module TestRail
3
+ class Client
4
+ # Methods for the Results API
5
+ # Use the following API methods to request details about test results and to add new test results.
6
+ #
7
+ # @see http://docs.gurock.com/testrail-api2/reference-results
8
+ #
9
+ # Returns a list of test results for a test.
10
+ #
11
+ # @param [Integer, String] test_id The ID of the test
12
+ # @return a list of test results for a test
13
+ # @see http://docs.gurock.com/testrail-api2/reference-results#get_results
14
+ def results(test_id)
15
+ get("get_results/#{test_id}")
16
+ end
17
+
18
+ #
19
+ # Returns a list of test results for a test run and case combination.
20
+ # The difference to get_results is that this method expects a test run + test case instead of a test. In TestRail,
21
+ # tests are part of a test run and the test cases are part of the related test suite.
22
+ # So, when you create a new test run, TestRail creates a test for each test case found in the test suite of the run.
23
+ # You can therefore think of a test as an “instance” of a test case which can have test results, comments and a test status.
24
+ # Please also see TestRail's getting started guide for more details about the differences between test cases and tests.
25
+ #
26
+ # This method uses the same response format as get_results.
27
+ #
28
+ # :run_id The ID of the test run
29
+ # :case_id The ID of the test case
30
+ #
31
+ def results_for_case(run_id, case_id)
32
+ get("get_results_for_case/#{run_id}/#{case_id}")
33
+ end
34
+
35
+ #
36
+ # Returns a list of test results for a test run.
37
+ #
38
+ # :run_id The ID of the test run
39
+ #
40
+ def results_for_run(run_id)
41
+ get("get_results_for_run/#{run_id}")
42
+ end
43
+
44
+ # TODO: add custom fields docs
45
+ #
46
+ # Adds a new test result, comment or assigns a test.
47
+ # It's recommended to use #add_results instead if you plan to add results for multiple tests.
48
+ #
49
+ # @param [Integer, String] test_id The ID of the test the result should be added to
50
+ # @param data [Hash]: Optional query data
51
+ # @option data [Integer, String] :status_id The ID of the test status. The built-in system statuses have the
52
+ # following IDs:
53
+ # 1 Passed
54
+ # 2 Blocked
55
+ # 3 Untested (not allowed when adding a result)
56
+ # 4 Retest
57
+ # 5 Failed
58
+ # You can get a full list of system and custom statuses via #TestRail#Client#Statuses#get_statuses.
59
+ # @option data [String] :comment The comment / description for the test result
60
+ # @option data [String] :version The version or build you tested against
61
+ # @option data [String] :elapsed The time it took to execute the test, e.g. "30s" or "1m 45s"
62
+ # @option data [Array<Integer>, Array<String>] :defects A comma-separated list of defects to link to the test result
63
+ # @option data [Integer, String] :assignedto_id The ID of a user the test should be assigned to
64
+ # @return the new test result using the same response format as get_results, but with a single result instead of a list of results.
65
+ # @see http://docs.gurock.com/testrail-api2/reference-results#add_result
66
+ def add_result(test_id, data)
67
+ post("add_result/#{test_id}", data)
68
+ end
69
+
70
+ #
71
+ # Adds a new test result, comment or assigns a test (for a test run and case combination).
72
+ # It's recommended to use add_results_for_cases instead if you plan to add results for multiple test cases.
73
+ # The difference to add_result is that this method expects a test run + test case instead of a test.
74
+ # In TestRail, tests are part of a test run and the test cases are part of the related test suite.
75
+ # So, when you create a new test run, TestRail creates a test for each test case found in the test suite of the run.
76
+ # You can therefore think of a test as an “instance” of a test case which can have test results, comments and a test status.
77
+ # Please also see TestRail's getting started guide for more details about the differences between test cases and tests.
78
+ #
79
+ # This method supports the same POST fields as add_result.
80
+ #
81
+ # :run_id The ID of the test run
82
+ # :case_id The ID of the test case
83
+ #
84
+ def add_result_for_case(run_id, case_id, data)
85
+ post("add_result_for_case/#{run_id}/#{case_id}", data)
86
+ end
87
+
88
+ #
89
+ # Adds a new test result, comment or assigns a test.
90
+ # It's recommended to use add_results instead if you plan to add results for multiple tests.
91
+ #
92
+ # :run_id The ID of the test run
93
+ #
94
+ def add_results(run_id, data)
95
+ post("add_results/#{run_id}", data)
96
+ end
97
+
98
+ #
99
+ # Adds one or more new test results, comments or assigns one or more tests (using the case IDs).
100
+ # Ideal for test automation to bulk-add multiple test results in one step.
101
+ #
102
+ # :run_id The ID of the test run the results should be added to
103
+ #
104
+ def add_results_for_cases(run_id, data)
105
+ post("add_results_for_cases/#{run_id}", data)
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,72 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Runs API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-runs
6
+ # Use the following API methods to request details about test runs and to create or modify test runs.
7
+
8
+ #
9
+ # Returns an existing test run. Please see get_tests for the list of included tests in this run.
10
+ #
11
+ # :run_id The ID of the test run
12
+ #
13
+ def run(run_id)
14
+ get("get_run/#{run_id}")
15
+ end
16
+
17
+ #
18
+ # Returns a list of test runs for a project.
19
+ # Only returns those test runs that are not part of a test plan (please see get_plans/get_plan for this).
20
+ #
21
+ # :project_id The ID of the project
22
+ #
23
+ def runs(project_id)
24
+ get("get_runs/#{project_id}")
25
+ end
26
+
27
+ #
28
+ # Creates a new test run.
29
+ #
30
+ # @param [Integer, String] project_id The ID of the project the test run should be added to
31
+ # @param data [Hash]: A customizable set of options
32
+ # @option data [Integer] :suite_id The ID of the test suite for the test run (optional if the project is operating in single suite mode, required otherwise)
33
+ # @option data [String] :name The name of the test run
34
+ # @option data [String] :description The description of the test run
35
+ # @option data [Integer] :milestone_id The ID of the milestone to link to the test run
36
+ # @option data [Integer] :assignedto_id The ID of the user the test run should be assigned to
37
+ # @option data [Boolean] :include_all True for including all test cases of the test suite and false for a custom case selection (default: true)
38
+ # @option data [Array<Integer>] :case_ids An array of case IDs for the custom case selection
39
+ # @return # TODO:
40
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
41
+ def add_run(project_id, data)
42
+ post("add_run/#{project_id}", data)
43
+ end
44
+
45
+ #
46
+ # Updates an existing test run (partial updates are supported, i.e. you can submit and update specific fields only).
47
+ #
48
+ # :run_id The ID of the test run
49
+ #
50
+ def update_run(run_id, data)
51
+ post("update_run/#{run_id}", data)
52
+ end
53
+
54
+ #
55
+ # Closes an existing test run and archives its tests & results.
56
+ #
57
+ # :run_id The ID of the test run
58
+ #
59
+ def close_run(run_id, data)
60
+ post("close_run/#{run_id}", data)
61
+ end
62
+
63
+ #
64
+ # Deletes an existing test run.
65
+ #
66
+ # :run_id The ID of the test run
67
+ #
68
+ def delete_run(run_id, data)
69
+ post("delete_run/#{run_id}", data)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,65 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Sections API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-sections
6
+ # Use the following API methods to request details about sections and to create or modify sections.
7
+ # Sections are used to group and organize test cases in test suites.
8
+
9
+ #
10
+ # Returns an existing section.
11
+ #
12
+ # :section_id The ID of the section
13
+ #
14
+ def section(section_id)
15
+ get("get_section/#{section_id}")
16
+ end
17
+
18
+ #
19
+ # Returns a list of sections for a project and test suite.
20
+ #
21
+ # :project_id The ID of the project
22
+ # :suite_id The ID of the test suite (optional if the project is operating in single suite mode)
23
+ #
24
+ def sections(project_id, suite_id)
25
+ get("get_sections/#{project_id}&suite_id=#{suite_id}")
26
+ end
27
+
28
+ def section_by_name(project_id, suite_id, section_name, ignore_case = true)
29
+ if ignore_case
30
+ sections(project_id, suite_id).find { |section| section['name'].casecmp(section_name) == 0 }
31
+ else
32
+ sections(project_id, suite_id).find { |section| section['name'] == section_name }
33
+ end
34
+ end
35
+
36
+ #
37
+ # Creates a new section.
38
+ #
39
+ # :project_id The ID of the project
40
+ #
41
+ def add_section(project_id, data)
42
+ post("add_section/#{project_id}", data)
43
+ end
44
+
45
+ #
46
+ # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
47
+ #
48
+ # :section_id The ID of the section
49
+ #
50
+ def update_section(section_id, data)
51
+ post("update_section/#{section_id}", data)
52
+ end
53
+
54
+ #
55
+ # Updates an existing section (partial updates are supported, i.e. you can submit and update specific fields only).
56
+ # Please note: Deleting a section cannot be undone and also deletes all related test cases
57
+ # as well as active tests & results, i.e. tests & results that weren't closed (archived) yet.
58
+ #
59
+ # :section_id The ID of the section
60
+ #
61
+ def delete_section(section_id)
62
+ post("delete_section/#{section_id}")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,19 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Statuses API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-statuses
6
+ # Use the following API methods to request details about test statuses.
7
+
8
+ # Each status has a unique ID, a name (system name) as well as a label (display name).
9
+ # The color related fields specify the different colors used for a status and are RGB colors.
10
+ # The following system statuses are available by default.
11
+ # You can add additional custom statuses under Administration > Customizations in TestRail.
12
+
13
+ # @return a list of available_contexts test statuses.
14
+ # @see http://docs.gurock.com/testrail-api2/reference-statuses#get_statuses
15
+ def statuses
16
+ get('get_statuses')
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,43 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Suites API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-suites
6
+ # Use the following API methods to request details about test suites and to create or modify test suites.
7
+
8
+ #
9
+ # Returns an existing test suite.
10
+ #
11
+ # :suite_id The ID of the test suite
12
+ #
13
+ def suite(suite_id)
14
+ get("get_suite/#{suite_id}")
15
+ end
16
+
17
+ def suite_by_name(project_id, suite_name, ignore_case = true)
18
+ if ignore_case
19
+ suites(project_id).find { |suite| suite['name'].casecmp(suite_name) == 0 }
20
+ else
21
+ suites(project_id).find { |suite| suite['name'] == suite_name }
22
+ end
23
+ end
24
+
25
+ #
26
+ # Returns a list of test suites for a project.
27
+ #
28
+ # :project_id The ID of the project
29
+ #
30
+ def suites(project_id)
31
+ get("get_suites/#{project_id}")
32
+ end
33
+
34
+ #
35
+ # Creates a new test suite.
36
+ #
37
+ # :project_id The ID of the project the test suite should be added to
38
+ #
39
+ def add_suite(project_id, data)
40
+ post("add_suite/#{project_id}", data)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,44 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Tests API
4
+ # Use the following API methods to request details about tests.
5
+ #
6
+ # @see http://docs.gurock.com/testrail-api2/reference-tests
7
+ #
8
+ # Returns an existing test by its ID
9
+ ##
10
+ # @param [Integer, String] test_id The ID of the test
11
+ # @return an existing test by its ID
12
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
13
+ def test(test_id)
14
+ get("get_test/#{test_id}")
15
+ end
16
+
17
+ # TODO: add documentation
18
+ def test_by_title(run_id, test_title, ignore_case = true)
19
+ if ignore_case
20
+ tests(run_id).find { |test| test['title'].casecmp(test_title) == 0 }
21
+ else
22
+ tests(run_id).find { |test| test['title'] == test_title }
23
+
24
+ end
25
+ end
26
+
27
+ # TODO: add documentation
28
+ def test_id_by_title(run_id, test_title)
29
+ test_by_title(run_id, test_title)['id']
30
+ end
31
+
32
+ #
33
+ # Returns a list of tests for a test run.
34
+ #
35
+ # # TODO: finish method and documentation
36
+ # @param [Integer, String] run_id The ID of the test run
37
+ # @option [String] status_id
38
+ # @return an existing test by its ID
39
+ # @see http://docs.gurock.com/testrail-api2/reference-runs#add_run
40
+ def tests(run_id)
41
+ get("get_tests/#{run_id}")
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,32 @@
1
+ module TestRail
2
+ class Client
3
+ # Methods for the Users API
4
+ #
5
+ # @see http://docs.gurock.com/testrail-api2/reference-users
6
+ #
7
+
8
+ # Returns an existing user.
9
+ #
10
+ # :user_id The ID of the user
11
+ #
12
+ def user(user_id)
13
+ get("get_user/#{user_id}")
14
+ end
15
+
16
+ #
17
+ # Returns a list of users.
18
+ #
19
+ def users
20
+ get('get_users')
21
+ end
22
+
23
+ #
24
+ # Returns an existing user by his/her email address.
25
+ #
26
+ # :email The email address to get the user for
27
+ #
28
+ def user_by_email(email)
29
+ get("get_user_by_email&email=#{email}")
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,15 @@
1
+ require 'testrail_api/client/case_fields'
2
+ require 'testrail_api/client/case_types'
3
+ require 'testrail_api/client/cases'
4
+ require 'testrail_api/client/milestones'
5
+ require 'testrail_api/client/plans'
6
+ require 'testrail_api/client/priorities'
7
+ require 'testrail_api/client/projects'
8
+ require 'testrail_api/client/result_fields'
9
+ require 'testrail_api/client/runs'
10
+ require 'testrail_api/client/sections'
11
+ require 'testrail_api/client/statuses'
12
+ require 'testrail_api/client/suites'
13
+ require 'testrail_api/client/suites'
14
+ require 'testrail_api/client/tests'
15
+ require 'testrail_api/client/users'
@@ -0,0 +1,3 @@
1
+ module TestRail
2
+ VERSION = '0.1.1'.freeze
3
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ require 'testrail_api/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'testrail_api'
9
+ spec.version = TestRail::VERSION
10
+ spec.platform = Gem::Platform::RUBY
11
+
12
+ spec.authors = ['Kirill Zhukov']
13
+ spec.email = ['zhukov.kirill.96@gmail.com']
14
+
15
+ spec.summary = 'Client for TestRail API v2'
16
+ spec.description = 'Wrapper for TestRail API v2'
17
+ spec.homepage = 'https://github.com/kirillzh/testrail_api'
18
+ spec.license = 'MIT'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.require_paths = ['lib']
22
+
23
+ # Dependencies
24
+ spec.add_development_dependency('bundler', '~> 1.10')
25
+ spec.add_development_dependency('rake', '~> 10.0')
26
+
27
+ spec.add_dependency('typhoeus', '~> 0.7.2')
28
+
29
+ spec.required_ruby_version = '>= 1.9.2'
30
+ spec.required_rubygems_version = '>= 1.3.5'
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testrail_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Zhukov
@@ -60,7 +60,31 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
63
65
  - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - lib/testrail_api.rb
69
+ - lib/testrail_api/client.rb
70
+ - lib/testrail_api/client/case_fields.rb
71
+ - lib/testrail_api/client/case_types.rb
72
+ - lib/testrail_api/client/cases.rb
73
+ - lib/testrail_api/client/milestones.rb
74
+ - lib/testrail_api/client/plans.rb
75
+ - lib/testrail_api/client/priorities.rb
76
+ - lib/testrail_api/client/projects.rb
77
+ - lib/testrail_api/client/result_fields.rb
78
+ - lib/testrail_api/client/results.rb
79
+ - lib/testrail_api/client/runs.rb
80
+ - lib/testrail_api/client/sections.rb
81
+ - lib/testrail_api/client/statuses.rb
82
+ - lib/testrail_api/client/suites.rb
83
+ - lib/testrail_api/client/tests.rb
84
+ - lib/testrail_api/client/users.rb
85
+ - lib/testrail_api/endpoints.rb
86
+ - lib/testrail_api/version.rb
87
+ - testrail_api.gemspec
64
88
  homepage: https://github.com/kirillzh/testrail_api
65
89
  licenses:
66
90
  - MIT