prestashop-automation-tool 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/pat +9 -1
- data/bin/pat-runner-invoice.rb +47 -20
- metadata +17 -1
data/bin/pat
CHANGED
@@ -49,6 +49,12 @@ elsif ARGV[0] == 'install'
|
|
49
49
|
ps.drop_database
|
50
50
|
ps.install options
|
51
51
|
end
|
52
|
+
elsif ARGV[0] == 'create' and ARGV[1] == 'tax' and ARGV[2] == 'group'
|
53
|
+
withConfig do |conf|
|
54
|
+
ps = PrestaShopAutomation::PrestaShop.new(conf[:shop])
|
55
|
+
ps.login_to_back_office
|
56
|
+
ps.create_tax_group_from_rate ARGV[3]
|
57
|
+
end
|
52
58
|
elsif ARGV[0] == 'create'
|
53
59
|
if ARGV[1]
|
54
60
|
template = File.join PrestaShopAutomationTool.gem_root, 'lib', 'templates', 'sample_test.rb'
|
@@ -119,8 +125,10 @@ elsif ARGV[0] == 'disable'
|
|
119
125
|
if ARGV[1]
|
120
126
|
`mv tests-enabled/#{ARGV[1]}.* tests-available/`
|
121
127
|
else
|
122
|
-
|
128
|
+
`mv tests-enabled/* tests-available/`
|
123
129
|
end
|
130
|
+
elsif ARGV[0] == 'clean'
|
131
|
+
`rm tests-output/*`
|
124
132
|
else
|
125
133
|
puts "Unknown command '#{ARGV[0]}'!"
|
126
134
|
end
|
data/bin/pat-runner-invoice.rb
CHANGED
@@ -1,9 +1,26 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
|
3
|
+
require 'pry'
|
3
4
|
require 'rspec'
|
4
5
|
require 'rspec/autorun'
|
5
6
|
require 'prestashop-automation-tool/helper'
|
6
7
|
|
8
|
+
def compare expected, got, path=[]
|
9
|
+
differences = {}
|
10
|
+
if got.is_a? Hash and expected.is_a? Hash
|
11
|
+
expected.each_pair do |key, value|
|
12
|
+
pkey = key.to_s.include?(".") ? "\"#{key}\"" : key
|
13
|
+
differences.merge! compare(expected[key], got[key], path + [pkey])
|
14
|
+
end
|
15
|
+
else
|
16
|
+
if got != expected
|
17
|
+
#abort "#{path.join('.')} :: got #{got} instead of #{expected}"
|
18
|
+
differences[path.join('.')] = "got #{got} instead of #{expected}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return differences
|
22
|
+
end
|
23
|
+
|
7
24
|
def test_invoice ps, scenario, options={}
|
8
25
|
|
9
26
|
taxes = {}
|
@@ -78,26 +95,36 @@ def test_invoice ps, scenario, options={}
|
|
78
95
|
ps.goto_back_office
|
79
96
|
invoice = ps.validate_order :id => order_id, :dump_pdf_to => options[:dump_pdf_to], :get_invoice_json => true
|
80
97
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
98
|
+
total_mapping = {
|
99
|
+
'to_pay_tax_included' => 'total_paid_tax_incl',
|
100
|
+
'to_pay_tax_excluded' => 'total_paid_tax_excl',
|
101
|
+
'products_tax_included' => 'total_products_wt',
|
102
|
+
'products_tax_excluded' => 'total_products',
|
103
|
+
'shipping_tax_included' => 'total_shipping_tax_incl',
|
104
|
+
'shipping_tax_excluded' => 'total_shipping_tax_excl',
|
105
|
+
'discounts_tax_included' => 'total_discounts_tax_incl',
|
106
|
+
'discounts_tax_excluded' => 'total_discounts_tax_excl',
|
107
|
+
'wrapping_tax_included' => 'total_wrapping_tax_incl',
|
108
|
+
'wrapping_tax_excluded' => 'total_wrapping_tax_excl'
|
109
|
+
}
|
110
|
+
|
111
|
+
got = {'invoice' => {
|
112
|
+
'total' => Hash[total_mapping.map do |to, from| [to, invoice['order'][from].to_f] end],
|
113
|
+
'tax' => {
|
114
|
+
'products' => Hash[invoice['tax_tab']['product_tax_breakdown'].map do |k,v|
|
115
|
+
[k.to_f.to_s, v['total_amount'].to_f]
|
116
|
+
end]
|
95
117
|
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
expected = scenario['expect']
|
122
|
+
|
123
|
+
differences = compare(expected, got)
|
124
|
+
|
125
|
+
if not differences.empty?
|
126
|
+
File.write (options[:output_prefix] + '.failed.json'), JSON.pretty_generate(differences)
|
127
|
+
throw differences
|
101
128
|
end
|
102
129
|
end
|
103
130
|
|
@@ -105,6 +132,6 @@ scenario = JSON.parse File.read(ENV['PAT_SOURCE'])
|
|
105
132
|
|
106
133
|
describe 'Invoice test' do
|
107
134
|
it 'should work' do
|
108
|
-
test_invoice @shop, scenario, :dump_pdf_to => (ENV['PAT_OUTPUT_PREFIX'] + '.pdf')
|
135
|
+
test_invoice @shop, scenario, :dump_pdf_to => (ENV['PAT_OUTPUT_PREFIX'] + '.pdf'), :output_prefix => ENV['PAT_OUTPUT_PREFIX']
|
109
136
|
end
|
110
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prestashop-automation-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.5'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pry
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: apache-vhosts-parser
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|