atm_ruby 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +2 -0
- data/.travis.yml +15 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Guardfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +6 -0
- data/atm_ruby.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/atm_ruby.rb +17 -0
- data/lib/atm_ruby/client.rb +43 -0
- data/lib/atm_ruby/configuration.rb +36 -0
- data/lib/atm_ruby/error_handeling/test_case_error.rb +16 -0
- data/lib/atm_ruby/error_handeling/test_plan_error.rb +16 -0
- data/lib/atm_ruby/error_handeling/test_run_error.rb +17 -0
- data/lib/atm_ruby/helpers/base_error.rb +24 -0
- data/lib/atm_ruby/helpers/base_service.rb +27 -0
- data/lib/atm_ruby/helpers/test_case.rb +11 -0
- data/lib/atm_ruby/services/test_case.rb +131 -0
- data/lib/atm_ruby/services/test_plan.rb +19 -0
- data/lib/atm_ruby/services/test_run.rb +137 -0
- data/lib/atm_ruby/version.rb +3 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40082bfe5827eb7255460ff08f07b3ca384e719b
|
4
|
+
data.tar.gz: b24f83804edc71cbe59b875c3f2799720e549d7c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b99a55f3d22b2f1bdff5f4feb220e9def096ac0226e03e6da91601df74df47228685ceb5c5798389ef6efd010aa5453babe03ecfbe826a6dd7d290986c514da
|
7
|
+
data.tar.gz: 3d92d8754a1f8116f945114156a71cd8ecc42905cb9f93db07ec994eb40b3953fb68e6634ba9ef1ac273ca3e34af217b3a85161908f1e26f9092fbcfee8e03dc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.1
|
5
|
+
before_install:
|
6
|
+
- gem update --system 2.6.12
|
7
|
+
deploy:
|
8
|
+
provider: rubygems
|
9
|
+
api_key:
|
10
|
+
secure: DfBHDVzua51mUPP13AaijPkr48GtqmCGPYEJvrHCaWyhmH7VRHRyphEC64It4J3NwgoT9WSsmTeyuc6dwuCQBY24RxXu33x/RwcMns/3qZoeJsp7XrWZFoL9a/gaAfZTz9ndZUc8wofZwnUdVXOHeWnZPCoyZFIt2gIXNV8JB146782ge9CFLU3WhtK0mCUKjxjEM4+ZvSNJiblYtwV2TSPulUz5z+dY0abrWIx2+jL6M4XRY4VuvOx416RulOdA3OrbvnLyC7dLyrdj6tVCsTv6QzcsYhlsAxMQLXqXrI0Pjjkw03ypyIkmynIl0oBstsCOKmqCFr9CiStwoHVq3YE3+rA9KuHWuFbXYKdlEfQeeUktdUQLETR9slZ2XVO7jVAhBnwntDd2Qdcl7B9CwqPc27m7Ow12Y3FMO5+1E70skhAKE1fFkvwauluF64k9NiwbukeJUM4y9daLE7bMqJkdm7y1GBJC0scK1tNpJY1+GsoYcRCtgavHs7OtdM9XSBjuo1GLXnLttGUDKrbzdO9iy+3OJJzSjaa6S6bPQvohCPiB9xRQwjKbTfUXzFqDaDSqC38X1azhQ4SN0J55qA2T4dOuDPArRTfPD1vjmq9rXnuL2g4PmeVWXlcTHi1/oP3NIG0eFHc/mF+/7PpNvx1/6lVrCYHrOSNtKxVbG0Y=
|
11
|
+
gem: atm_ruby
|
12
|
+
on:
|
13
|
+
tags: true
|
14
|
+
repo: automation-wizards/atm_ruby
|
15
|
+
branch: master
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at frbk@users.noreply.github.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Adaptavist Test Management API Wrapper
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/atm_ruby.svg)](https://badge.fury.io/rb/atm_ruby)
|
3
|
+
[![Build Status](https://travis-ci.org/automation-wizards/atm_ruby.svg?branch=master)](https://travis-ci.org/automation-wizards/atm_ruby)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/github/automation-wizards/atm_ruby/badge.svg?branch=master)](https://coveralls.io/github/automation-wizards/atm_ruby?branch=master)
|
5
|
+
[![Inline docs](http://inch-ci.org/github/automation-wizards/atm_ruby.svg?branch=master)](http://inch-ci.org/github/automation-wizards/atm_ruby)
|
6
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/automation-wizards/atm_ruby.svg)](https://gemnasium.com/github.com/automation-wizards/atm_ruby)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'atm_ruby'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install atm_ruby
|
23
|
+
|
24
|
+
## Usage(Look for API refferences [here](https://www.kanoah.com/docs/public-api/1.0/))
|
25
|
+
|
26
|
+
#### Configuration
|
27
|
+
|
28
|
+
Setup configuration in your setup file if you need to configure it once
|
29
|
+
```ruby
|
30
|
+
ATM.configure do |c|
|
31
|
+
c.base_url = 'http://localhost'
|
32
|
+
c.auth_type = :basic
|
33
|
+
c.project_id = 'PD'
|
34
|
+
c.test_run_id = 'TR-I123'
|
35
|
+
c.environment = 'Mobile'
|
36
|
+
c.username = 'Test'
|
37
|
+
c.password = 'test'
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Or do it everytime you create a client
|
42
|
+
```ruby
|
43
|
+
client = ATM::Client.new(base_url: 'http://localhost', auth_type: :basic,
|
44
|
+
project_id: 'PD', test_run_id: 'TR-I123',
|
45
|
+
environment: 'Mobile', username: 'Test', password: 'test')
|
46
|
+
```
|
47
|
+
|
48
|
+
## Development
|
49
|
+
|
50
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
|
+
|
52
|
+
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).
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/atm_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
57
|
+
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/atm_ruby.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'atm_ruby/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'atm_ruby'
|
9
|
+
spec.version = ATM::VERSION
|
10
|
+
spec.authors = ['azohra']
|
11
|
+
spec.email = ['']
|
12
|
+
|
13
|
+
spec.summary = 'Adaptavist Test Management API Wrapper'
|
14
|
+
spec.description = 'Methods to work with test management for jira api.'
|
15
|
+
spec.homepage = 'https://github.com/azohra/atm_ruby'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
19
|
+
f.match(%r{^(test|spec|features)/})
|
20
|
+
end
|
21
|
+
spec.bindir = 'exe'
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_runtime_dependency 'httparty', '~> 0.15.3'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
27
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
|
+
spec.add_development_dependency 'coveralls', '~> 0.8.20'
|
30
|
+
spec.add_development_dependency 'pry', '~> 0.10.4'
|
31
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
|
32
|
+
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
33
|
+
spec.add_development_dependency 'webmock', '~> 3.0', '>= 3.0.1'
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'atm_ruby'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
|
+
|
13
|
+
# require 'irb'
|
14
|
+
# IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/atm_ruby.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
require 'atm_ruby/version'
|
4
|
+
require 'atm_ruby/configuration'
|
5
|
+
require 'atm_ruby/helpers/base_service'
|
6
|
+
|
7
|
+
require 'atm_ruby/error_handeling/test_plan_error'
|
8
|
+
require 'atm_ruby/error_handeling/test_case_error'
|
9
|
+
require 'atm_ruby/error_handeling/test_run_error'
|
10
|
+
|
11
|
+
require 'atm_ruby/services/test_plan'
|
12
|
+
require 'atm_ruby/services/test_case'
|
13
|
+
require 'atm_ruby/services/test_run'
|
14
|
+
|
15
|
+
require 'atm_ruby/client'
|
16
|
+
|
17
|
+
ATM.configure { ; }
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'base64'
|
2
|
+
|
3
|
+
module ATM
|
4
|
+
# ATM::Client client for working with Adaptavist Test Management.
|
5
|
+
class Client
|
6
|
+
attr_accessor :auth_header
|
7
|
+
|
8
|
+
def initialize(**args)
|
9
|
+
options = ATM.config.to_hash.merge(args)
|
10
|
+
options.each do |key, value|
|
11
|
+
singleton_class.class_eval { attr_accessor key }
|
12
|
+
send("#{key}=", value)
|
13
|
+
end
|
14
|
+
case options[:auth_type]
|
15
|
+
when :basic then @auth_header = set_access_token
|
16
|
+
else raise 'Currently only supports basic authentication'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def gen_auth_token
|
21
|
+
(Base64.encode64(username + ':' + password)[0..-2]).to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_access_token
|
25
|
+
{ 'Authorization' => "Basic #{gen_auth_token}",
|
26
|
+
'Content-Type' => 'application/json' }
|
27
|
+
end
|
28
|
+
|
29
|
+
def TestPlan
|
30
|
+
ATM::Services::TestPlan.new(auth_header: auth_header, base_url: base_url)
|
31
|
+
end
|
32
|
+
|
33
|
+
def TestCase
|
34
|
+
ATM::Services::TestCase.new(auth_header: auth_header, base_url: base_url,
|
35
|
+
environment: environment, project_id: project_id)
|
36
|
+
end
|
37
|
+
|
38
|
+
def TestRun
|
39
|
+
ATM::Services::TestRun.new(auth_header: auth_header, base_url: base_url,
|
40
|
+
environment: environment, test_run_id: test_run_id)
|
41
|
+
end
|
42
|
+
end # Client
|
43
|
+
end # ATM
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# :nodoc:
|
2
|
+
module ATM
|
3
|
+
class << self
|
4
|
+
attr_accessor :config
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.configure
|
8
|
+
self.config ||= Configuration.new
|
9
|
+
yield(config)
|
10
|
+
end
|
11
|
+
|
12
|
+
# :nodoc: TODO
|
13
|
+
class Configuration
|
14
|
+
attr_accessor :base_url, :test_run_id,
|
15
|
+
:environment, :username,
|
16
|
+
:password, :project_id, :auth_type
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
@base_url = nil
|
20
|
+
@test_run_id = nil
|
21
|
+
@project_id = nil
|
22
|
+
@environment = nil
|
23
|
+
@username = nil
|
24
|
+
@password = nil
|
25
|
+
@auth_type = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
def to_hash
|
29
|
+
hash = {}
|
30
|
+
instance_variables.each do |var|
|
31
|
+
hash[var.to_s.delete('@').to_sym] = instance_variable_get(var)
|
32
|
+
end
|
33
|
+
hash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../helpers/base_error'
|
2
|
+
module ATM
|
3
|
+
class TestCaseError < ATM::BaseError
|
4
|
+
attr_reader :message
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
@response = response
|
8
|
+
@message = case response.code
|
9
|
+
when 400 then raise_400
|
10
|
+
when 401 then raise_401
|
11
|
+
when 404 then raise_404('No Test Case has been found with the given key.')
|
12
|
+
when 500 then raise_500
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'atm_ruby/helpers/base_error'
|
2
|
+
|
3
|
+
module ATM
|
4
|
+
class TestPlanError < ATM::BaseError
|
5
|
+
attr_reader :message
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
|
+
@message = case response.code
|
10
|
+
when 401 then raise_401
|
11
|
+
when 404 then raise_404('No Test Plan has been found with the given key')
|
12
|
+
when 500 then raise_500
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative '../helpers/base_error'
|
2
|
+
|
3
|
+
module ATM
|
4
|
+
class TestRunError < ATM::BaseError
|
5
|
+
attr_reader :message
|
6
|
+
|
7
|
+
def initialize(response)
|
8
|
+
@response = response
|
9
|
+
@message = case response.code
|
10
|
+
when 400 then raise_400
|
11
|
+
when 401 then raise_401
|
12
|
+
when 404 then raise_404('No Test Run has been found with the given key.')
|
13
|
+
when 500 then raise_500
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ATM
|
2
|
+
class BaseError < StandardError
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
def_instance_delegators :response, :code
|
6
|
+
attr_reader :response
|
7
|
+
|
8
|
+
def raise_400
|
9
|
+
"\nStatus Code: 400\nError Message:\n#{response.parsed_response['errorMessages'].join("\n")}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def raise_401
|
13
|
+
"\nStatus Code: 401\nError Message: Client must be authenticated to access this resource."
|
14
|
+
end
|
15
|
+
|
16
|
+
def raise_404(error_message)
|
17
|
+
"\nStatus Code: 404\nError Message: #{error_message}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def raise_500
|
21
|
+
"\nStatus Code: 500\nError Message: Internal server error."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module ATM
|
4
|
+
module Services
|
5
|
+
# ATM::Services::Base Base class for all of the services
|
6
|
+
#
|
7
|
+
# @attr_reader [] response - holds data after post/put/delete/get submited
|
8
|
+
# @attr_reader [Hash] header - access token for authentication
|
9
|
+
# @attr_reader [String] project_id - user set project id
|
10
|
+
#
|
11
|
+
class Base
|
12
|
+
include HTTParty
|
13
|
+
extend Forwardable
|
14
|
+
|
15
|
+
default_options.update(verify: false)
|
16
|
+
format :json
|
17
|
+
|
18
|
+
attr_reader :auth_header, :response
|
19
|
+
def_delegators :@response, :code, :body, :header
|
20
|
+
|
21
|
+
def initialize(**args)
|
22
|
+
self.class.base_uri args[:base_url]
|
23
|
+
@auth_header = args[:auth_header]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'atm_ruby/helpers/test_case'
|
2
|
+
module ATM
|
3
|
+
module Services
|
4
|
+
# ATM::Services::TestCase provides methods for working with test cases
|
5
|
+
#
|
6
|
+
# @see https://www.kanoah.com/docs/public-api/1.0/ more info regarding test cases can be found here
|
7
|
+
#
|
8
|
+
class TestCase < ATM::Services::Base
|
9
|
+
include ATM::Helper::TestCase
|
10
|
+
|
11
|
+
attr_accessor :environment, :project_id
|
12
|
+
|
13
|
+
def initialize(**args)
|
14
|
+
@project_id = args.delete(:project_id)
|
15
|
+
@environment = args.delete(:environment)
|
16
|
+
super(args)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Creates new test case
|
20
|
+
#
|
21
|
+
# @param [Hash] body
|
22
|
+
#
|
23
|
+
# @example Create new test case
|
24
|
+
# ATM::Client.new.TestCase.create({"projectKey": "JQA", "name": "Ensure the axial-flow pump is enabled"})
|
25
|
+
#
|
26
|
+
def create(body)
|
27
|
+
self.class.post('/rest/kanoahtests/1.0/testcase', body: body.to_json, headers: auth_header).tap do |r|
|
28
|
+
@response = r
|
29
|
+
raise ATM::TestCaseError, response unless code == 201
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Updates test case
|
34
|
+
#
|
35
|
+
# @param [String] test_case_key
|
36
|
+
#
|
37
|
+
# @example Update existing test case
|
38
|
+
#
|
39
|
+
def update(test_case_id, body)
|
40
|
+
self.class.put("/rest/kanoahtests/1.0/testcase/#{test_case_id}", body: body.to_json, headers: auth_header).tap do |r|
|
41
|
+
@response = r
|
42
|
+
raise ATM::TestCaseError, response unless code == 200
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Deletes test case
|
47
|
+
#
|
48
|
+
# @param [String] test_case_key
|
49
|
+
#
|
50
|
+
# @example Delete existing test case
|
51
|
+
#
|
52
|
+
def delete(test_case_id)
|
53
|
+
self.class.delete("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |r|
|
54
|
+
@response = r
|
55
|
+
raise ATM::TestCaseError, response unless code == 204
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Finds specific test case
|
60
|
+
#
|
61
|
+
# @param [String] test_case_key
|
62
|
+
#
|
63
|
+
# @example Find existing test case
|
64
|
+
#
|
65
|
+
def find(test_case_id)
|
66
|
+
self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}", headers: auth_header).tap do |r|
|
67
|
+
@response = r
|
68
|
+
raise ATM::TestCaseError, response unless code == 200
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Searches for test cases based on the provided quiry
|
73
|
+
#
|
74
|
+
# @param [String] query_string
|
75
|
+
#
|
76
|
+
# @example Search for an existed test case
|
77
|
+
#
|
78
|
+
def search(query_string)
|
79
|
+
self.class.get("/rest/kanoahtests/1.0/testcase/search?query=#{query_string}", headers: auth_header).tap do |r|
|
80
|
+
@response = r
|
81
|
+
raise ATM::TestCaseError, response unless code == 200
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
# Adds attachment to a test case
|
86
|
+
#
|
87
|
+
# @param [String] tese_case_id
|
88
|
+
#
|
89
|
+
# @example Add attachment to an existed test case
|
90
|
+
#
|
91
|
+
def add_attachment(_test_case_id) # TODO: need to fix this.
|
92
|
+
warn 'Not implemented at the moment'
|
93
|
+
# self.class.get("/rest/kanoahtests/1.0/testcase/#{test_case_id}/attachment", headers: auth_header).tap do |r|
|
94
|
+
# raise ATM::TestCaseError, response unless response.code == 201
|
95
|
+
# end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Create new result for test case
|
99
|
+
#
|
100
|
+
# @param [Hash] test_data
|
101
|
+
#
|
102
|
+
# @example
|
103
|
+
# test_data = { project: "GG", test_case: 'GG-T1'}
|
104
|
+
# ATM::Client.new.TestCase.create_new_test_result(test_data)
|
105
|
+
#
|
106
|
+
def create_new_test_result(test_data)
|
107
|
+
self.class.post('/rest/kanoahtests/1.0/testresult', body: test_data.to_json, headers: auth_header).tap do |r|
|
108
|
+
@response = r
|
109
|
+
raise ATM::TestCaseError, response unless code == 200
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
# Creates hash for new test result
|
114
|
+
#
|
115
|
+
# @param [Hash] test_data
|
116
|
+
def process_result(test_data)
|
117
|
+
{
|
118
|
+
'projectKey' => test_data.fetch(:project_id, project_id),
|
119
|
+
'testCaseKey' => test_data[:test_case],
|
120
|
+
'status' => test_data.fetch(:status, nil),
|
121
|
+
'environment' => test_data.fetch(:environment, environment),
|
122
|
+
'userKey' => test_data.fetch(:username, nil),
|
123
|
+
'comment' => test_data.fetch(:comment, nil),
|
124
|
+
'executionTime' => test_data.fetch(:execution_time, nil),
|
125
|
+
'executionDate' => test_data.fetch(:execution_date, nil),
|
126
|
+
'scriptResults' => test_data.fetch(:script_results, nil)
|
127
|
+
}.delete_if { |_k, v| v.nil? }
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ATM
|
2
|
+
module Services
|
3
|
+
# ATM::Services::TestPlan
|
4
|
+
class TestPlan < ATM::Services::Base
|
5
|
+
# Retrives data for specific test plan
|
6
|
+
#
|
7
|
+
# @param [String] plan_key
|
8
|
+
#
|
9
|
+
# @example Retrive data for a plan_key
|
10
|
+
# plan_data = ATM::CLinet.new.TestPlan.find('RR-P20')
|
11
|
+
def find(plan_key)
|
12
|
+
self.class.get("/rest/kanoahtests/1.0/testplan/#{plan_key.upcase}", headers: auth_header).tap do |response|
|
13
|
+
@response = response
|
14
|
+
raise ATM::TestPlanError, response unless response.code == 200
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,137 @@
|
|
1
|
+
module ATM
|
2
|
+
module Services
|
3
|
+
# ATM::Services::TestRun provides methods for working with test runs
|
4
|
+
#
|
5
|
+
# @see https://www.kanoah.com/docs/public-api/1.0/ more info regarding test cases can be found here
|
6
|
+
#
|
7
|
+
class TestRun < ATM::Services::Base
|
8
|
+
attr_reader :test_run_id, :environment
|
9
|
+
|
10
|
+
def initialize(**args)
|
11
|
+
@test_run_id = args.delete(:test_run_id)
|
12
|
+
@environment = args.delete(:environment)
|
13
|
+
super(args)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Creates new test run
|
17
|
+
#
|
18
|
+
# @param [Hash] test_run_data
|
19
|
+
#
|
20
|
+
# @example Create new test case
|
21
|
+
# ATM::Client.new.TestRun.create({"name": "Full regression","projectKey": "JQA"})
|
22
|
+
#
|
23
|
+
def create(test_run_data)
|
24
|
+
self.class.post("/rest/kanoahtests/1.0/testrun", body: test_run_data.to_json, headers: auth_header).tap do |r|
|
25
|
+
@response = r
|
26
|
+
raise ATM::TestRunError, response unless code == 201
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Retrive specific test run
|
31
|
+
#
|
32
|
+
# @param [String] test_run_id
|
33
|
+
#
|
34
|
+
# @example Create new test case
|
35
|
+
# ATM::Client.new.TestRun.find('DD-R123')
|
36
|
+
#
|
37
|
+
def find(test_run_id)
|
38
|
+
self.class.get("/rest/kanoahtests/1.0/testrun/#{test_run_id}", headers: auth_header).tap do |r|
|
39
|
+
@response = r
|
40
|
+
raise ATM::TestRunError, response unless code == 200
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete specific test run
|
45
|
+
#
|
46
|
+
# @param [String] test_run_id
|
47
|
+
#
|
48
|
+
# @example Create new test case
|
49
|
+
# ATM::Client.new.TestRun.delete('DD-R123')
|
50
|
+
#
|
51
|
+
def delete(test_run_id)
|
52
|
+
self.class.delete("/rest/kanoahtests/1.0/testrun/#{test_run_id}", headers: auth_header).tap do |r|
|
53
|
+
@response = r
|
54
|
+
raise ATM::TestRunError, response unless code == 204
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Searches for a testrun based on the provided quiry
|
59
|
+
#
|
60
|
+
# @param [String] test_run_id
|
61
|
+
#
|
62
|
+
# @example Create new test case
|
63
|
+
# ATM::Client.new.TestRun.search('projectKey = "JQA"')
|
64
|
+
#
|
65
|
+
def search(query_string)
|
66
|
+
self.class.get("/rest/kanoahtests/1.0/testrun/search?query=#{query_string}", headers: auth_header).tap do |r|
|
67
|
+
@response = r
|
68
|
+
raise ATM::TestRunError, response unless code == 200
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Create new result for a test run
|
73
|
+
#
|
74
|
+
# @param [String] test_run_key
|
75
|
+
# @param [String] test_case_id
|
76
|
+
# @param [Hash] test_data
|
77
|
+
#
|
78
|
+
# @example
|
79
|
+
# test_data = {
|
80
|
+
# "status": "Fail",
|
81
|
+
# "scriptResults": [
|
82
|
+
# {
|
83
|
+
# "index": 0,
|
84
|
+
# "status": "Fail",
|
85
|
+
# "comment": "This steps has failed."
|
86
|
+
# }
|
87
|
+
# ]
|
88
|
+
# }
|
89
|
+
# ATM::Client.new.TestRun.create_new_test_run_result('DD-R123','DD-T123', test_data)
|
90
|
+
#
|
91
|
+
def create_new_test_run_result(test_run_key = @test_run_id, test_case_id, test_data)
|
92
|
+
self.class.post("/rest/kanoahtests/1.0/testrun/#{test_run_key}/testcase/#{test_case_id}/testresult", body: test_data.to_json, headers: auth_header).tap do |r|
|
93
|
+
@response = r
|
94
|
+
raise ATM::TestRunError, response unless code == 201
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Update latest result for a test run
|
99
|
+
#
|
100
|
+
# @param [String] test_run_key
|
101
|
+
# @param [String] test_case_id
|
102
|
+
# @param [Hash] test_data
|
103
|
+
#
|
104
|
+
# @example
|
105
|
+
# test_data = {
|
106
|
+
# "status": "Fail",
|
107
|
+
# "scriptResults": [
|
108
|
+
# {
|
109
|
+
# "index": 0,
|
110
|
+
# "status": "Fail",
|
111
|
+
# "comment": "This steps has failed."
|
112
|
+
# }
|
113
|
+
# ]
|
114
|
+
# }
|
115
|
+
# ATM::Client.new.TestRun.update_last_test_run_result('DD-R123','DD-T123', test_data)
|
116
|
+
#
|
117
|
+
def update_last_test_run_result(test_run_key = @test_run_id, test_case_id, test_data)
|
118
|
+
self.class.post("/rest/kanoahtests/1.0/testrun/#{test_run_key}/testcase/#{test_case_id}/testresult", body: test_data.to_json, headers: auth_header).tap do |r|
|
119
|
+
@response = r
|
120
|
+
end
|
121
|
+
# raise ATM::TestRunError, response unless response.code == 200
|
122
|
+
end
|
123
|
+
|
124
|
+
def process_result(test_data)
|
125
|
+
{
|
126
|
+
'status' => test_data[:status],
|
127
|
+
'environment' => test_data.fetch(:environment, @environment),
|
128
|
+
'comment' => test_data.fetch(:comment, nil),
|
129
|
+
'userKey' => test_data.fetch(:username, nil),
|
130
|
+
'executionTime' => test_data.fetch(:execution_time, nil),
|
131
|
+
'executionDate' => test_data.fetch(:execution_date, nil),
|
132
|
+
'scriptResults' => test_data[:script_results]
|
133
|
+
}.delete_if { |k, v| v.nil? }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: atm_ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.16
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- azohra
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.15.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.15.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.8.20
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.8.20
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.10.4
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.10.4
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.7'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 4.7.3
|
107
|
+
type: :development
|
108
|
+
prerelease: false
|
109
|
+
version_requirements: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '4.7'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 4.7.3
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: vcr
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '3.0'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 3.0.3
|
127
|
+
type: :development
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '3.0'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 3.0.3
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: webmock
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '3.0'
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 3.0.1
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '3.0'
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 3.0.1
|
157
|
+
description: Methods to work with test management for jira api.
|
158
|
+
email:
|
159
|
+
- ''
|
160
|
+
executables: []
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files: []
|
163
|
+
files:
|
164
|
+
- ".gitignore"
|
165
|
+
- ".rspec"
|
166
|
+
- ".travis.yml"
|
167
|
+
- CODE_OF_CONDUCT.md
|
168
|
+
- Gemfile
|
169
|
+
- Guardfile
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.md
|
172
|
+
- Rakefile
|
173
|
+
- atm_ruby.gemspec
|
174
|
+
- bin/console
|
175
|
+
- bin/setup
|
176
|
+
- lib/atm_ruby.rb
|
177
|
+
- lib/atm_ruby/client.rb
|
178
|
+
- lib/atm_ruby/configuration.rb
|
179
|
+
- lib/atm_ruby/error_handeling/test_case_error.rb
|
180
|
+
- lib/atm_ruby/error_handeling/test_plan_error.rb
|
181
|
+
- lib/atm_ruby/error_handeling/test_run_error.rb
|
182
|
+
- lib/atm_ruby/helpers/base_error.rb
|
183
|
+
- lib/atm_ruby/helpers/base_service.rb
|
184
|
+
- lib/atm_ruby/helpers/test_case.rb
|
185
|
+
- lib/atm_ruby/services/test_case.rb
|
186
|
+
- lib/atm_ruby/services/test_plan.rb
|
187
|
+
- lib/atm_ruby/services/test_run.rb
|
188
|
+
- lib/atm_ruby/version.rb
|
189
|
+
homepage: https://github.com/azohra/atm_ruby
|
190
|
+
licenses:
|
191
|
+
- MIT
|
192
|
+
metadata: {}
|
193
|
+
post_install_message:
|
194
|
+
rdoc_options: []
|
195
|
+
require_paths:
|
196
|
+
- lib
|
197
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
requirements: []
|
208
|
+
rubyforge_project:
|
209
|
+
rubygems_version: 2.5.1
|
210
|
+
signing_key:
|
211
|
+
specification_version: 4
|
212
|
+
summary: Adaptavist Test Management API Wrapper
|
213
|
+
test_files: []
|