services_automation 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'http://gems.despegar.com'
2
+ source 'http://rubygems.org'
3
+
4
+ gem 'rspec'
5
+ gem 'httparty'
6
+ gem 'result'
7
+ gem 'henry-container'
8
+ gem 'service-despegar-ds'
9
+ gem 'relevant_cities'
10
+ gem 'nokogiri'
11
+
12
+ group :development do
13
+ gem 'debugger'
14
+ gem 'pry'
15
+ gem 'pry-doc'
16
+ gem 'pry-nav'
17
+ end
data/henry-context.yml ADDED
@@ -0,0 +1,43 @@
1
+ tasks:
2
+ - name: WIP
3
+ class_name: Henry::Task::RspecTask
4
+ options:
5
+ tags:
6
+ - wip
7
+
8
+ - name: SEARCH_INSURANCE
9
+ class_name: Henry::Task::RspecTask
10
+ options:
11
+ tags:
12
+ - search_insurance
13
+
14
+ - name: RETRIEVE_INSURANCE
15
+ class_name: Henry::Task::RspecTask
16
+ options:
17
+ tags:
18
+ - retrieve_insurance
19
+ # #format: json
20
+
21
+ - name: SEARCH_TICKET
22
+ class_name: Henry::Task::RspecTask
23
+ options:
24
+ tags:
25
+ - search_ticket
26
+
27
+ - name: RETRIEVE_TICKET
28
+ class_name: Henry::Task::RspecTask
29
+ options:
30
+ tags:
31
+ - retrieve_ticket
32
+
33
+ - name: SEARCH_TOUR
34
+ class_name: Henry::Task::RspecTask
35
+ options:
36
+ tags:
37
+ - search_tour
38
+
39
+ - name: RETRIEVE_TOUR
40
+ class_name: Henry::Task::RspecTask
41
+ options:
42
+ tags:
43
+ - retrieve_tour
@@ -0,0 +1,60 @@
1
+ module ServicesAutomation
2
+
3
+ class DSSM < ServiceDs
4
+
5
+ SERVICE_SERVER = 'http://10.2.7.16/ds-sm'
6
+ SERVICE_METHOD = 'get'
7
+
8
+ def status
9
+ {"code" => "SUCCEEDED","messages"=> nil} if !data.nil?
10
+ end
11
+
12
+ def get_search_path
13
+ raise 'This method should be implemented in the concrete class'
14
+ end
15
+
16
+ def do_call
17
+
18
+ call_path = generate_path
19
+
20
+ put_cookie_as_header
21
+
22
+ args = {:timeout => timeout, :limit => 1000, :headers =>{'X-UOW' => 'DS-BOT'}}
23
+
24
+ @cache = request(method, call_path, args) if !cache_status
25
+
26
+ self.cache_status = true
27
+
28
+ check_status
29
+
30
+ puts " Service URL: #{get_debug_url_info}"
31
+
32
+ @cache
33
+ rescue MissingParam => exception
34
+ raise("ERROR: #{exception.message}")
35
+ rescue SocketError
36
+ raise("ERROR - #{get_debug_url_info} - URL Inexistente")
37
+ rescue Errno::ECONNRESET
38
+ raise("ERROR - #{get_debug_url_info} - Conection Reset")
39
+ rescue Errno::ECONNREFUSED
40
+ raise("ERROR - #{get_debug_url_info} - Conetion Refused")
41
+ rescue Errno::EHOSTUNREACH
42
+ raise("ERROR - #{get_debug_url_info} - Host Unreachable")
43
+ rescue Timeout::Error
44
+ raise("ERROR - #{get_debug_url_info} - Time Out")
45
+ rescue Errno::ETIMEDOUT
46
+ raise("ERROR - #{get_debug_url_info} - Time Out")
47
+ rescue EmptyCache => exception
48
+ raise('ERROR - There was an internal error and cache was left empty')
49
+ rescue DataNull
50
+ raise("ERROR - Data from service was null or empty => #{get_debug_url_info} ==> got #{cache}")
51
+ rescue StatusNull
52
+ raise("ERROR - Status from service was null or empty #{get_debug_url_info} ==> got #{cache}")
53
+ rescue ServiceError => exception
54
+ raise("ERROR - #{exception.message} - #{get_debug_url_info}")
55
+ rescue Exception => exception
56
+ raise("UNKNOWN ERROR - Maybe service: #{get_uri} is not available or is not responding, with params #{get_final_path}, exception message: #{exception.message}\n Backtrace: #{exception.backtrace}, cache:#{cache}")
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,138 @@
1
+ require 'pry'
2
+
3
+ module ServicesAutomation
4
+
5
+ class Retrieve < DSSM
6
+
7
+ def initialize(*args)
8
+ super
9
+ set_server(args[0] || SERVICE_SERVER)
10
+ set_path(args[1] || get_service_path)
11
+ set_method(args[2] || SERVICE_METHOD)
12
+ run_search(args[0] || SERVICE_SERVER)
13
+ end
14
+
15
+ def get_dto
16
+ raise 'Destination Service DTO cannot be empty' if cache['data']['destinationServiceDTO'].empty?
17
+ cache['data']['destinationServiceDTO']
18
+ end
19
+
20
+ def run_search()
21
+ raise 'This method should be implemented in the concrete class'
22
+ end
23
+
24
+ def get_service_id
25
+ raise 'destinationServiceID cannot be null' if cache['data']['destinationServiceDTO']['destinationServiceId'].nil?
26
+ cache['data']['destinationServiceDTO']['destinationServiceId']
27
+ end
28
+
29
+ def get_service_name
30
+ raise 'destinationServiceName cannot be null' if cache['data']['destinationServiceDTO']['destinationServiceName'].nil?
31
+ cache['data']['destinationServiceDTO']['destinationServiceName']
32
+ end
33
+
34
+ def get_service_description
35
+ cache['data']['destinationServiceDTO']['destinationServiceDescription']
36
+ end
37
+
38
+ def get_language
39
+ raise 'language cannot be null' if cache['data']['destinationServiceDTO']['language'].nil?
40
+ cache['data']['destinationServiceDTO']['language']
41
+ end
42
+
43
+ def get_home_iata
44
+ raise 'homeIATA cannot be null' if cache['data']['destinationServiceDTO']['homeIATA'].nil?
45
+ cache['data']['destinationServiceDTO']['homeIATA']
46
+ end
47
+
48
+ def get_destination_iata
49
+ raise 'destinationIATA cannot be null' if cache['data']['destinationServiceDTO']['destinationIATA'].nil?
50
+ cache['data']['destinationServiceDTO']['destinationIATA']
51
+ end
52
+
53
+ def get_from_date
54
+ raise 'from date cannot be null' if cache['data']['destinationServiceDTO']['from'].nil?
55
+ cache['data']['destinationServiceDTO']['from']
56
+ end
57
+
58
+ def get_to_date
59
+ raise 'to date cannot be null' if cache['data']['destinationServiceDTO']['to'].nil?
60
+ cache['data']['destinationServiceDTO']['to']
61
+ end
62
+
63
+ def get_distribution
64
+ raise 'distribution cannot be null' if cache['data']['destinationServiceDTO']['distribution'].nil?
65
+ cache['data']['destinationServiceDTO']['distribution']
66
+ end
67
+
68
+ def get_provider
69
+ raise 'destinationServiceProvider cannot be null' if cache['data']['destinationServiceDTO']['destinationServiceProvider'].nil?
70
+ cache['data']['destinationServiceDTO']['destinationServiceProvider']
71
+ end
72
+
73
+ def get_service_type
74
+ raise 'destinationServiceType cannot be null' if cache['data']['destinationServiceDTO']['destinationServiceType'].nil?
75
+ cache['data']['destinationServiceDTO']['destinationServiceType']
76
+ end
77
+
78
+ def get_adult_max_age
79
+ raise 'adultMaxAge cannot be null' if cache['data']['destinationServiceDTO']['adultMaxAge'].nil?
80
+ cache['data']['destinationServiceDTO']['adultMaxAge']
81
+ end
82
+
83
+ def get_child_max_age
84
+ cache['data']['destinationServiceDTO']['childMaxAge']
85
+ end
86
+
87
+ def get_infant_max_age
88
+ cache['data']['destinationServiceDTO']['infantMaxAge']
89
+ end
90
+
91
+ def get_prices
92
+ raise 'Prices cannot be empty' if cache['data']['destinationServiceDTO']['prices'].empty?
93
+ cache['data']['destinationServiceDTO']['prices']
94
+ end
95
+
96
+ def get_payment_plans
97
+ raise 'creditCardPaymentPlans cannot be empty' if cache['data']['destinationServiceDTO']['creditCardPaymentPlans'].empty?
98
+ cache['data']['destinationServiceDTO']['creditCardPaymentPlans']
99
+ end
100
+
101
+ def get_cancellation_policies
102
+ #raise 'cancellationPolicies cannot be empty' if cache['data']['destinationServiceDTO']['cancellationPolicies'].nil?
103
+ cache['data']['destinationServiceDTO']['cancellationPolicies']
104
+ end
105
+
106
+ def get_highlights
107
+ cache['data']['destinationServiceDTO']['highlights']
108
+ end
109
+
110
+ def get_particular_conditions
111
+ cache['data']['destinationServiceDTO']['particularCondition']
112
+ end
113
+
114
+ def get_product_type
115
+ cache['data']['destinationServiceDTO']['parentProductType']
116
+ end
117
+
118
+ def get_additionals
119
+ cache['data']['destinationServiceDTO']['additionals']
120
+ end
121
+
122
+ def get_price_by_currency(currency = "USD")
123
+ raise "The price should always be returned" if get_prices.select { | price | price['currency'] == "#{currency}" }.empty?
124
+ get_prices.select { | price | price['currency'] == "#{currency}" }.first
125
+ end
126
+
127
+ def get_total_price(currency = "USD")
128
+ raise "The total price cannot be null" if get_price_by_currency(currency)['totalPrice'].nil?
129
+ get_price_by_currency(currency)['roundedTotalPrice']
130
+ end
131
+
132
+ def set_total_price_to_config
133
+ raise "The total price cannot be null" if get_total_price.nil?
134
+ CONFIG[:retrieveTotalPrice] = get_total_price
135
+ end
136
+
137
+ end
138
+ end
@@ -0,0 +1,31 @@
1
+ require 'pry'
2
+
3
+ module ServicesAutomation
4
+ ##
5
+ # search params
6
+ # {searchHash}/{serviceType}
7
+
8
+ class RetrieveInsurance < Retrieve
9
+
10
+ SERVICE_PATH = '/service/search/insurance/retrieve' \
11
+ + '/:searchHash' \
12
+ + '/:serviceId'
13
+
14
+ def get_service_path
15
+ SERVICE_PATH
16
+ end
17
+
18
+ def run_search(server)
19
+ search = ServicesAutomation::SearchInsurance.new(server)
20
+ search.set_flight_price_to_params
21
+ search.set_params(CONFIG[:params])
22
+
23
+ search.run
24
+ CONFIG[:params][:serviceId] = search.get_service_id
25
+ search.set_search_hash_to_config
26
+ search.set_total_price_to_config(CONFIG[:params][:serviceId])
27
+
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,46 @@
1
+ require 'pry'
2
+
3
+ module ServicesAutomation
4
+ ##
5
+ # search params
6
+ # {searchHash}/{serviceType}
7
+
8
+ class RetrieveTicket < Retrieve
9
+
10
+ SERVICE_PATH = ''
11
+
12
+ def get_service_path
13
+ if CONFIG[:hasAdditionals]
14
+ SERVICE_PATH.replace get_service_path_with_additionals
15
+ else
16
+ SERVICE_PATH.replace get_service_path_without_additionals
17
+ end
18
+ end
19
+
20
+ def get_service_path_with_additionals
21
+ path = '/service/search/ticket/retrieve' \
22
+ + '/:searchHash' \
23
+ + '/:serviceId' \
24
+ '/:additionals'
25
+ end
26
+
27
+ def get_service_path_without_additionals
28
+ path = '/service/search/ticket/retrieve' \
29
+ + '/:searchHash' \
30
+ + '/:serviceId'
31
+ end
32
+
33
+ def run_search(server)
34
+ search = ServicesAutomation::SearchTicket.new(server)
35
+ search.set_params(CONFIG[:params])
36
+ search.run
37
+ search.set_search_hash_to_config
38
+
39
+ search.set_service_id_to_config
40
+ search.set_total_price_to_config(CONFIG[:params][:serviceId]) if !CONFIG[:hasAdditionals]
41
+ search.set_additionals_to_config(CONFIG[:params][:additionals], search) if CONFIG[:hasAdditionals]
42
+
43
+ end
44
+
45
+ end
46
+ end
@@ -0,0 +1,29 @@
1
+ require 'pry'
2
+
3
+ module ServicesAutomation
4
+ ##
5
+ # search params
6
+ # {searchHash}/{serviceType}
7
+
8
+ class RetrieveTour < Retrieve
9
+
10
+ SERVICE_PATH = '/service/search/tour/retrieve' \
11
+ + '/:searchHash' \
12
+ + '/:serviceId'
13
+
14
+ def get_service_path
15
+ SERVICE_PATH
16
+ end
17
+
18
+ def run_search(server)
19
+ search = ServicesAutomation::SearchTour.new(server)
20
+ search.set_params(CONFIG[:params])
21
+ search.run
22
+ CONFIG[:params][:serviceId] = search.get_service_id
23
+ search.set_search_hash_to_config
24
+ search.set_total_price_to_config(CONFIG[:params][:serviceId])
25
+
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,96 @@
1
+ module ServicesAutomation
2
+ ##
3
+ # search params
4
+ # /{lang}/{country}/{destination}/{fromDate}/{toDate}/
5
+ #{distribution}/{flowOrigin}/{flightPrice}/{filters}/{sortBy}/{pagination}/{currencies}
6
+
7
+ class Search < DSSM
8
+
9
+ def initialize(*args)
10
+ super
11
+ set_server(args[0] || SERVICE_SERVER)
12
+ set_path(args[1] || get_search_path)
13
+ set_method(args[2] || SERVICE_METHOD)
14
+ end
15
+
16
+ def get_hash
17
+ raise "Hash cannot be null" if cache['data']['searchHash'].nil?
18
+ cache['data']['searchHash']
19
+ end
20
+
21
+ def get_all_services
22
+ raise "No results found for the performed search" if cache['data']['services'].empty?
23
+ cache['data']['services']
24
+ end
25
+
26
+ def get_random_service_id
27
+ raise "No services found for the performed search" if get_all_services.empty?
28
+ get_all_services.shuffle.first['serviceId']
29
+ end
30
+
31
+ def get_service(serviceId = '')
32
+ raise "No services found for the performed search" if get_all_services.empty?
33
+ if serviceId == ''
34
+ get_all_services.shuffle.first
35
+ else
36
+ get_service_by_id(serviceId)
37
+ end
38
+ end
39
+
40
+ def get_name
41
+ raise "Service name cannot be null" if get_service['name'].nil?
42
+ get_service['name']
43
+ end
44
+
45
+ def get_service_id
46
+ raise "Service ID cannot be null" if get_service['serviceId'].nil?
47
+ get_service['serviceId']
48
+ end
49
+
50
+ def get_provider
51
+ raise "Service provider cannot be null" if get_service['provider'].nil?
52
+ get_service['provider']
53
+ end
54
+
55
+ def get_service_type
56
+ raise "Service type cannot be null" if get_service['serviceType'].nil?
57
+ get_service['serviceType']
58
+ end
59
+
60
+ def get_service_by_id(serviceId)
61
+ raise "Ticket with service Id #{serviceId} was not found on search" if get_all_services.select { | service | service['serviceId'] == "#{serviceId}" }.empty?
62
+ get_all_services.select { | service | service['serviceId'] == "#{serviceId}" }
63
+ end
64
+
65
+ def get_prices(serviceId)
66
+
67
+ raise "Prices cannot be empty" if get_service(serviceId).first['prices'].empty?
68
+ get_service(serviceId).first['prices']
69
+ end
70
+
71
+ def get_price_by_currency(currency = "USD", serviceId)
72
+ raise "The price should always be returned" if get_prices(serviceId).fetch("#{currency}").empty?
73
+ get_prices(serviceId).fetch("#{currency}")
74
+ end
75
+
76
+ def get_total_price(currency = "USD", serviceId)
77
+ raise "The total price cannot be null" if get_price_by_currency(currency, serviceId)['totalPrice'].nil?
78
+
79
+ get_price_by_currency(currency, serviceId)['totalPrice']
80
+ end
81
+
82
+ def set_total_price_to_config(serviceId)
83
+ raise "The total price cannot be null" if get_total_price("USD", serviceId).nil?
84
+ CONFIG[:searchTotalPrice] = get_total_price("USD", serviceId)
85
+ end
86
+
87
+ def set_search_hash_to_config
88
+ CONFIG[:params][:searchHash] = get_hash
89
+ end
90
+
91
+ def set_service_id_to_config
92
+ CONFIG[:params][:serviceId] = get_service_id
93
+ end
94
+
95
+ end
96
+ end
@@ -0,0 +1,32 @@
1
+ module ServicesAutomation
2
+ ##
3
+ # search params
4
+ # /{lang}/{country}/{destination}/{fromDate}/{toDate}/
5
+ #{distribution}/{flowOrigin}/{flightPrice}/{filters}/{sortBy}/{pagination}/{currencies}
6
+
7
+ class SearchInsurance < Search
8
+
9
+ SERVICE_PATH = '/service/search/insurance' \
10
+ + '/:language' \
11
+ + '/:country' \
12
+ + '/:destination' \
13
+ + '/:fromDate' \
14
+ + '/:toDate' \
15
+ + '/:distribution' \
16
+ + '/:flowOrigin' \
17
+ + '/:flightPrice' \
18
+ + '/:filters' \
19
+ + '/:sortBy' \
20
+ + '/:pagination' \
21
+ + '/:currencies'
22
+
23
+ def get_search_path
24
+ SERVICE_PATH
25
+ end
26
+
27
+ def set_flight_price_to_params
28
+
29
+ CONFIG[:params][:flightPrice] = ENVIRONMENT[:flightPrice]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,53 @@
1
+ module ServicesAutomation
2
+ ##
3
+ # search params
4
+ # /{lang}/{country}/{destination}/{fromDate}/{toDate}/
5
+ #search/ticket/ES/CL/ORL/NA/NA/3/DESTINATION_SERVICE/PROVIDER:DISNEY/PriceASC/1-20/ARS
6
+
7
+ class SearchTicket < Search
8
+
9
+ SERVICE_PATH = '/service/search/ticket' \
10
+ + '/:language' \
11
+ + '/:country' \
12
+ + '/:destination' \
13
+ + '/:fromDate' \
14
+ + '/:toDate' \
15
+ + '/:distribution' \
16
+ + '/:flowOrigin' \
17
+ + '/:filters' \
18
+ + '/:sortBy' \
19
+ + '/:pagination' \
20
+ + '/:currencies'
21
+
22
+ def get_search_path
23
+ SERVICE_PATH
24
+ end
25
+
26
+ def get_additionals(ticket)
27
+ get_service(ticket).first['additionals']
28
+ end
29
+
30
+ def get_additional_ids(ticket)
31
+ additionals = []
32
+ get_additionals(CONFIG[:params][:serviceId]).each do | additional |
33
+ additionals << additional[1]['serviceId']
34
+ end
35
+ additionals
36
+ end
37
+
38
+ def get_additionals_for_params(ticket)
39
+ additionals = get_additional_ids(ticket)
40
+
41
+ additionalsForParams = additionals.pop
42
+ while additionals.size > 0 do
43
+ additionalsForParams += ',' + additionals.pop
44
+ end
45
+ additionalsForParams
46
+ end
47
+
48
+ def set_additionals_to_config(additionals, ticket)
49
+ CONFIG[:params][:additionals] = get_additionals_for_params(ticket) if additionals.eql?('')
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,23 @@
1
+ module ServicesAutomation
2
+ #/tours?lang=ES&home=AR&destination=CUN&from=2014-05-03&to=2014-05-30&distribution=1&product_type=DESTINATION_SERVICE&filters=NA&sorting=PriceASC&paging=1-20
3
+
4
+ class SearchTour < Search
5
+
6
+ SERVICE_PATH = '/service/tours?' \
7
+ + 'lang=:language' \
8
+ + '&home=:country' \
9
+ + '&destination=:destination' \
10
+ + '&from=:fromDate' \
11
+ + '&to=:toDate' \
12
+ + '&distribution=:distribution' \
13
+ + '&product_type=:flowOrigin' \
14
+ + '&filters=:filters' \
15
+ + '&sorting=:sortBy' \
16
+ + '&paging=:pagination'
17
+
18
+ def get_search_path
19
+ SERVICE_PATH
20
+ end
21
+
22
+ end
23
+ end
data/lib/services.rb ADDED
@@ -0,0 +1,17 @@
1
+ # dependencies gems needed for services
2
+ require 'service_ds'
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+
6
+ # services that depends on service_gem
7
+ require_relative './services/ds_sm.rb'
8
+ #Search Requires
9
+ require_relative './services/search.rb'
10
+ require_relative './services/search_insurance.rb'
11
+ require_relative './services/search_tour.rb'
12
+ require_relative './services/search_ticket.rb'
13
+ #Retrieve Requires
14
+ require_relative './services/retrieve.rb'
15
+ require_relative './services/retrieve_insurance.rb'
16
+ require_relative './services/retrieve_tour.rb'
17
+ require_relative './services/retrieve_ticket.rb'
@@ -0,0 +1,3 @@
1
+ module ServicesAutomation
2
+ VERSION = "0.0.22"
3
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'services_automation/version'
2
+ require_relative './services.rb'
3
+ require_relative 'validators/validator.rb'
4
+
5
+ module ServicesAutomation
6
+
7
+ end
File without changes
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/services_automation/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "services_automation"
6
+ gem.version = ServicesAutomation::VERSION
7
+ gem.authors = ["Santiago Ochoa"]
8
+ gem.email = %w{sochoa@despegar.com}
9
+ gem.description = %q{DS Services testing Gem}
10
+ gem.summary = %q{Automation Testing for DS Services}
11
+ gem.homepage = "http://gems.despegar.com"
12
+ gem.files = Dir[".henry/**/file"] +
13
+ Dir["services_automation.gemspec"] +
14
+ Dir["Gemfile"] +
15
+ Dir['spec/**/*.rb'] +
16
+ Dir['henry-context.yml'] +
17
+ Dir['lib/**/*.rb']
18
+
19
+ gem.add_dependency('henry-container')
20
+ end
data/spec/core_spec.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe ServicesAutomation do
4
+
5
+ context "Integration with service_gem" do
6
+ it "should be able to instance search object", :wip => true do
7
+ search = ServicesAutomation::Search.new()
8
+ search.should be_respond_to(:cache)
9
+ search.should be_respond_to(:set_path)
10
+ search.should be_respond_to(:method)
11
+ search.should be_respond_to(:server)
12
+ search.should be_respond_to(:params)
13
+ search.should be_respond_to(:set_server)
14
+ search.should be_respond_to(:data)
15
+ search.should be_respond_to(:run)
16
+ end
17
+ end
18
+
19
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/retrieve_spec.rb'
3
+
4
+ describe ServicesAutomation::RetrieveInsurance do
5
+
6
+ before(:all) do
7
+ @insurance_retrieve = ServicesAutomation::RetrieveInsurance.new()
8
+ @insurance_retrieve.set_params(CONFIG[:params])
9
+ @insurance_retrieve.run
10
+ end
11
+
12
+ context "Insurance validations" do
13
+
14
+ it_behaves_like "Retrieve common validations", :retrieve_insurance do
15
+ let (:retrieve) { @insurance_retrieve }
16
+ end
17
+
18
+ it "Should return sth", :retrieve_insurance => true do
19
+ !@insurance_retrieve.nil?
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/retrieve_spec.rb'
3
+
4
+ describe ServicesAutomation::RetrieveTicket do
5
+
6
+ before(:all) do
7
+ @ticket_retrieve = ServicesAutomation::RetrieveTicket.new()
8
+ @ticket_retrieve.set_params(CONFIG[:params])
9
+ @ticket_retrieve.run
10
+
11
+
12
+ end
13
+
14
+ context "Ticket validations" do
15
+
16
+ it_behaves_like "Retrieve common validations", :retrieve_ticket do
17
+ let (:retrieve) { @ticket_retrieve }
18
+ end
19
+
20
+ it "Should return sth", :retrieve_ticket => true do
21
+ !@ticket_retrieve.nil?
22
+ end
23
+
24
+ it "Should return a commission higher than 0", :retrieve_ticket => true do
25
+
26
+ base_price = @ticket_retrieve.get_price_by_currency("USD")['basePrice']
27
+ provider_price = @ticket_retrieve.get_price_by_currency("USD")['providerPrice']
28
+ price_difference = base_price - provider_price
29
+ price_difference.should be > 0
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/retrieve_spec.rb'
3
+
4
+ describe ServicesAutomation::RetrieveTour do
5
+
6
+ before(:all) do
7
+ @tour_retrieve = ServicesAutomation::RetrieveTour.new()
8
+ @tour_retrieve.set_params(CONFIG[:params])
9
+ @tour_retrieve.run
10
+ end
11
+
12
+ context "Tour validations" do
13
+
14
+ it_behaves_like "Retrieve common validations", :retrieve_tour do
15
+ let (:retrieve) { @tour_retrieve }
16
+ end
17
+
18
+ it "Should return sth", :retrieve_tour => true do
19
+ !@tour_retrieve.nil?
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/search_spec.rb'
3
+
4
+ describe ServicesAutomation::SearchInsurance do
5
+
6
+ before(:all) do
7
+ @insurance_search = ServicesAutomation::SearchInsurance.new()
8
+ #@insurance_search.set_flight_price_to_params
9
+ @insurance_search.set_params(CONFIG[:params])
10
+ @insurance_search.run
11
+ @insurance_search.set_service_id_to_config if CONFIG[:params][:serviceId].eql?('')
12
+ end
13
+
14
+ context "Insurance Validations" do
15
+
16
+ it "Should return sth", :search_insurance => true do
17
+ !@insurance_search.nil?
18
+ end
19
+
20
+ it_behaves_like "Search common validations", :search_insurance do
21
+ let(:search) { @insurance_search }
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/search_spec.rb'
3
+
4
+ describe ServicesAutomation::SearchTicket do
5
+ ## PROBAR USANDO LET EN VEZ DE BEFORE PARA TODOS
6
+ before(:all) do
7
+ @ticket_search = ServicesAutomation::SearchTicket.new()
8
+ @ticket_search.set_params(CONFIG[:params])
9
+ @ticket_search.run
10
+ @ticket_search.set_service_id_to_config if CONFIG[:params][:serviceId] = ''
11
+ puts 'performing search'
12
+ end
13
+
14
+ context "Ticket validations" do
15
+ describe "All ticket validations" do
16
+ it_behaves_like "Search common validations", :search_ticket do
17
+ let (:search) { @ticket_search }
18
+ end
19
+
20
+ it "Should return sth", :search_ticket => true do
21
+ !@ticket_search.nil?
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper.rb'
2
+ require_relative 'shared_examples/search_spec.rb'
3
+
4
+ describe ServicesAutomation::SearchTour do
5
+
6
+ before(:all) do
7
+ @tour_search = ServicesAutomation::SearchTour.new()
8
+ #@insurance_search.set_flight_price_to_params
9
+ @tour_search.set_params(CONFIG[:params])
10
+ @tour_search.run
11
+ @tour_search.set_service_id_to_config if CONFIG[:params][:serviceId].eql?('')
12
+ end
13
+
14
+ context "Tour Validations" do
15
+
16
+ it "Should return sth", :search_tour => true do
17
+ !@tour_search.nil?
18
+ end
19
+
20
+ it_behaves_like "Search common validations", :search_tour do
21
+ let(:search) { @tour_search }
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require_relative '../spec_helper.rb'
2
+
3
+ shared_examples "Retrieve common validations" do | service |
4
+
5
+ describe ServicesAutomation::Retrieve do
6
+
7
+ context "Service Response Validation" do
8
+
9
+ it "Should return the retrieve DTO", service => true do
10
+ retrieve.get_dto
11
+ end
12
+ end
13
+
14
+ context "Service data validation" do
15
+ if !CONFIG[:hasAdditionals]
16
+
17
+ it "Should return the total price and be the same as in the search", service => true do
18
+ retrieve.get_total_price.should eql(CONFIG[:searchTotalPrice])
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,84 @@
1
+ require_relative '../spec_helper.rb'
2
+ require 'pry'
3
+
4
+
5
+ shared_examples "Search common validations" do | service |
6
+
7
+ describe ServicesAutomation::Search do
8
+
9
+ # before(:all) do
10
+ #
11
+ # #search.set_flight_price_to_params
12
+ # search.set_params(CONFIG[:params])
13
+ # search.run
14
+ # end
15
+
16
+ context "Service Response Validation" do
17
+
18
+ it "Should have a searchHash", service => true do
19
+ search.get_hash.should be_is_a(String)
20
+ end
21
+
22
+ it "Should have at least one insurance result", service => true do
23
+ search.get_all_services
24
+
25
+ end
26
+ end
27
+
28
+ context "Service Information" do
29
+
30
+ it "Should have a name", service => true do
31
+ search.get_name
32
+ end
33
+
34
+ it "Should have a Service ID", service => true do
35
+ search.get_service_id
36
+ end
37
+
38
+ it "Should have a Provider", service => true do
39
+ search.get_provider
40
+ end
41
+
42
+ it "Should have a Service Type", service => true do
43
+ search.get_service_type
44
+ end
45
+
46
+ it "Should return the corresponding list of prices", service => true do
47
+ search.get_prices(CONFIG[:params][:serviceId])
48
+ end
49
+
50
+ it "Should return at least one currency", service => true do
51
+ prices = search.get_prices(CONFIG[:params][:serviceId])
52
+ currencies = []
53
+ prices.each do | price |
54
+ currencies << price[1]['currency']
55
+ end
56
+ currencies.empty?.should be_falsey
57
+
58
+ puts "Params => #{CONFIG[:params]}"
59
+
60
+ end
61
+
62
+ end
63
+ end
64
+ end
65
+
66
+ # describe ServicesAutomation::SearchInsurance do
67
+
68
+ # @insurance_search = ServicesAutomation::SearchInsurance.new()
69
+
70
+ # service
71
+
72
+ # it_behaves_like "Search common validations", @insurance_search, :search_insurance
73
+
74
+ # end
75
+
76
+ # describe ServicesAutomation::SearchTransfer do
77
+
78
+ # @insurance_search = ServicesAutomation::SearchTransfer.new()
79
+
80
+ # service
81
+
82
+ # it_behaves_like "Search common validations", @insurance_search, :search_transfer
83
+
84
+ # end
@@ -0,0 +1,73 @@
1
+ require_relative '../lib/services_automation.rb'
2
+
3
+ require 'henry/environment'
4
+ require 'httparty'
5
+
6
+ include ServicesAutomation
7
+
8
+
9
+ CONFIG = {} unless defined?(CONFIG)
10
+
11
+ ##
12
+ # Usamos esto para que las hints se puedan especificar como symbol
13
+ RSpec.configure do |c|
14
+
15
+ c.treat_symbols_as_metadata_keys_with_true_values = true
16
+
17
+ ##
18
+ # Ejemplo :=> ENVIRONMENT = params[:key]
19
+ begin
20
+ timeFrom = Time.now + 10000000
21
+ timeTo = timeFrom + 1000000
22
+
23
+ params = Henry::Environment.params
24
+ ENVIRONMENT = {}
25
+ ENVIRONMENT[:cookies] = params[:cookies] || '{}'
26
+ ENVIRONMENT[:server] = params[:server] || '10.2.7.16/ds-sm'
27
+ ENVIRONMENT[:country] = params['country'] || %W{BR CL CO MX}.shuffle.first
28
+ ENVIRONMENT[:currencies] = params[:currencies] || 'USD'
29
+ ENVIRONMENT[:distribution] = params[:distribution] || '2'
30
+ ## to know if the destination comes as a string or as an array
31
+ if !params['destination'].is_a? String
32
+ destination = params['destination'].nil? ? params['destination'] : params['destination'].to_a.shuffle.first
33
+ else
34
+ destination = params['destination']
35
+ end
36
+ ENVIRONMENT[:destination] = destination || %W{SAO ORL BUE MIA NYC RIO MDZ}.shuffle.first
37
+ ENVIRONMENT[:language] = params[:language] || 'es'
38
+ ENVIRONMENT[:fromDate] = params['fromDate'] || (Time.now + 10000000).strftime("%Y-%m-%d")
39
+ ENVIRONMENT[:toDate] = params['toDate'] || (Time.now + 11000000).strftime("%Y-%m-%d")
40
+ ENVIRONMENT[:flowOrigin] = params[:flowOrigin] || 'DESTINATION_SERVICE'
41
+ ENVIRONMENT[:flightPrice] = params[:flightPrice] || '1'
42
+ ENVIRONMENT[:filters] = params['filters'] || 'NA'
43
+ ENVIRONMENT[:sortBy] = params[:sortBy] || 'PriceASC'
44
+ ENVIRONMENT[:pagination] = params[:pagination] || '1-20'
45
+ ENVIRONMENT[:serviceId] = params['serviceId'] || ''
46
+ ENVIRONMENT[:disneyPrice] = params['disneyPrice'] || ''
47
+ ENVIRONMENT[:additionals] = params['additionals'] || ''
48
+ ## Set additionals as an empty string on params to exclude additionals
49
+ ENVIRONMENT[:hasAdditionals] = !ENVIRONMENT[:additionals].eql?('')
50
+
51
+ end unless defined?(ENVIRONMENT)
52
+ end
53
+
54
+ CONFIG[:params] = {
55
+ :country => ENVIRONMENT[:country],
56
+ :currencies => ENVIRONMENT[:currencies],
57
+ :distribution => ENVIRONMENT[:distribution],
58
+ :destination => ENVIRONMENT[:destination],
59
+ :language => ENVIRONMENT[:language],
60
+ :fromDate => ENVIRONMENT[:fromDate],
61
+ :toDate => ENVIRONMENT[:toDate],
62
+ :flowOrigin => ENVIRONMENT[:flowOrigin],
63
+ :flightPrice => ENVIRONMENT[:flightPrice],
64
+ :filters => ENVIRONMENT[:filters],
65
+ :sortBy => ENVIRONMENT[:sortBy],
66
+ :pagination => ENVIRONMENT[:pagination],
67
+ :searchHash => '',
68
+ :serviceId => ENVIRONMENT[:serviceId],
69
+ :additionals => ENVIRONMENT[:additionals]
70
+ }
71
+
72
+ CONFIG[:disneyPrice] = ENVIRONMENT[:disneyPrice]
73
+ CONFIG[:hasAdditionals] = ENVIRONMENT[:hasAdditionals]
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: services_automation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.22
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Santiago Ochoa
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: henry-container
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: DS Services testing Gem
31
+ email:
32
+ - sochoa@despegar.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - services_automation.gemspec
38
+ - Gemfile
39
+ - spec/retrieve_insurance_spec.rb
40
+ - spec/search_insurance_spec.rb
41
+ - spec/search_ticket_spec.rb
42
+ - spec/shared_examples/retrieve_spec.rb
43
+ - spec/shared_examples/search_spec.rb
44
+ - spec/spec_helper.rb
45
+ - spec/retrieve_ticket_spec.rb
46
+ - spec/search_tour_spec.rb
47
+ - spec/core_spec.rb
48
+ - spec/retrieve_tour_spec.rb
49
+ - henry-context.yml
50
+ - lib/services_automation.rb
51
+ - lib/validators/validator.rb
52
+ - lib/services/retrieve.rb
53
+ - lib/services/search.rb
54
+ - lib/services/retrieve_tour.rb
55
+ - lib/services/search_insurance.rb
56
+ - lib/services/retrieve_ticket.rb
57
+ - lib/services/retrieve_insurance.rb
58
+ - lib/services/search_ticket.rb
59
+ - lib/services/search_tour.rb
60
+ - lib/services/ds_sm.rb
61
+ - lib/services.rb
62
+ - lib/services_automation/version.rb
63
+ homepage: http://gems.despegar.com
64
+ licenses: []
65
+ post_install_message:
66
+ rdoc_options: []
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.25
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Automation Testing for DS Services
87
+ test_files: []
88
+ has_rdoc: