aspose_html_cloud 19.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,111 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="object_exist.rb">
5
+ </copyright>
6
+ Copyright (c) 2019 Aspose.HTML for Cloud
7
+ <summary>
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </summary>
26
+ --------------------------------------------------------------------------------------------------------------------
27
+ =end
28
+
29
+ require_relative 'base_model'
30
+
31
+ module AsposeHtml
32
+ # Object exists
33
+ class ObjectExist < BaseModel
34
+ # Indicates that the file or folder exists.
35
+ attr_accessor :exists
36
+
37
+ # True if it is a folder, false if it is a file.
38
+ attr_accessor :is_folder
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'exists' => :'exists',
44
+ :'is_folder' => :'isFolder'
45
+ }
46
+ end
47
+
48
+ # Attribute type mapping.
49
+ def self.model_types
50
+ {
51
+ :'exists' => :'BOOLEAN',
52
+ :'is_folder' => :'BOOLEAN'
53
+ }
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ return unless attributes.is_a?(Hash)
60
+
61
+ # convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
63
+
64
+ if attributes.has_key?(:'exists')
65
+ self.exists = attributes[:'exists']
66
+ end
67
+
68
+ if attributes.has_key?(:'is_folder')
69
+ self.is_folder = attributes[:'is_folder']
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ invalid_properties = Array.new
77
+ if @exists.nil?
78
+ invalid_properties.push('invalid value for "exists", exists cannot be nil.')
79
+ end
80
+
81
+ if @is_folder.nil?
82
+ invalid_properties.push('invalid value for "is_folder", is_folder cannot be nil.')
83
+ end
84
+
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ return false if @exists.nil?
92
+ return false if @is_folder.nil?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ exists == o.exists &&
102
+ is_folder == o.is_folder
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Fixnum] Hash code
107
+ def hash
108
+ [exists, is_folder].hash
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,96 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="storage_exist.rb">
5
+ </copyright>
6
+ Copyright (c) 2019 Aspose.HTML for Cloud
7
+ <summary>
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </summary>
26
+ --------------------------------------------------------------------------------------------------------------------
27
+ =end
28
+
29
+ require_relative 'base_model'
30
+
31
+ module AsposeHtml
32
+ # Storage exists
33
+ class StorageExist < BaseModel
34
+ # Shows that the storage exists.
35
+ attr_accessor :exists
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'exists' => :'exists'
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.model_types
46
+ {
47
+ :'exists' => :'BOOLEAN'
48
+ }
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ return unless attributes.is_a?(Hash)
55
+
56
+ # convert string to symbol for hash key
57
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
58
+
59
+ if attributes.has_key?(:'exists')
60
+ self.exists = attributes[:'exists']
61
+ end
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properties with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ if @exists.nil?
69
+ invalid_properties.push('invalid value for "exists", exists cannot be nil.')
70
+ end
71
+
72
+ invalid_properties
73
+ end
74
+
75
+ # Check to see if the all the properties in the model are valid
76
+ # @return true if the model is valid
77
+ def valid?
78
+ return false if @exists.nil?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ exists == o.exists
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Fixnum] Hash code
92
+ def hash
93
+ [exists].hash
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,135 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="storage_file.rb">
5
+ </copyright>
6
+ Copyright (c) 2019 Aspose.HTML for Cloud
7
+ <summary>
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </summary>
26
+ --------------------------------------------------------------------------------------------------------------------
27
+ =end
28
+
29
+ require_relative 'base_model'
30
+
31
+ module AsposeHtml
32
+ # File or folder information
33
+ class StorageFile < BaseModel
34
+ # File or folder name.
35
+ attr_accessor :name
36
+
37
+ # True if it is a folder.
38
+ attr_accessor :is_folder
39
+
40
+ # File or folder last modified DateTime.
41
+ attr_accessor :modified_date
42
+
43
+ # File or folder size.
44
+ attr_accessor :size
45
+
46
+ # File or folder path.
47
+ attr_accessor :path
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'name' => :'name',
53
+ :'is_folder' => :'isFolder',
54
+ :'modified_date' => :'modifiedDate',
55
+ :'size' => :'size',
56
+ :'path' => :'path'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.model_types
62
+ {
63
+ :'name' => :'String',
64
+ :'is_folder' => :'BOOLEAN',
65
+ :'modified_date' => :'DateTime',
66
+ :'size' => :'Integer',
67
+ :'path' => :'String'
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
78
+
79
+ if attributes.has_key?(:'name')
80
+ self.name = attributes[:'name']
81
+ end
82
+
83
+ if attributes.has_key?(:'isFolder')
84
+ self.is_folder = attributes[:'isFolder']
85
+ end
86
+
87
+ if attributes.has_key?(:'modifiedDate')
88
+ self.modified_date = attributes[:'modifiedDate']
89
+ end
90
+
91
+ if attributes.has_key?(:'size')
92
+ self.size = attributes[:'size']
93
+ end
94
+
95
+ if attributes.has_key?(:'path')
96
+ self.path = attributes[:'path']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ if @is_folder.nil?
105
+ invalid_properties.push('invalid value for "is_folder", is_folder cannot be nil.')
106
+ end
107
+
108
+ if @size.nil?
109
+ invalid_properties.push('invalid value for "size", size cannot be nil.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ return false if @is_folder.nil?
119
+ return false if @size.nil?
120
+ true
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ name == o.name &&
129
+ is_folder == o.is_folder &&
130
+ modified_date == o.modified_date &&
131
+ size == o.size &&
132
+ path == o.path
133
+ end
134
+ end
135
+ end
@@ -0,0 +1,31 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="version.rb">
5
+ </copyright>
6
+ Copyright (c) 2019 Aspose.HTML for Cloud
7
+ <summary>
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </summary>
26
+ --------------------------------------------------------------------------------------------------------------------
27
+ =end
28
+
29
+ module AsposeHtml
30
+ VERSION = "1.0.0"
31
+ end
@@ -0,0 +1,2612 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="html_api_spec.rb">
5
+ </copyright>
6
+ Copyright (c) 2019 Aspose.HTML for Cloud
7
+ <summary>
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </summary>
26
+ --------------------------------------------------------------------------------------------------------------------
27
+ =end
28
+
29
+ require 'spec_helper'
30
+ require 'json'
31
+
32
+ describe 'Test html_api' do
33
+ before(:all) do
34
+ # run before all tests
35
+ @instance = AsposeHtml::HtmlApi.new CONFIG
36
+ end
37
+
38
+ describe 'test an instance of HtmlApi' do
39
+ it 'should create an instance of HtmlApi' do
40
+ expect(@instance).to be_instance_of(AsposeHtml::HtmlApi)
41
+ end
42
+ end
43
+
44
+ #################################################
45
+ # Conversion API
46
+ #################################################
47
+
48
+ # unit tests for get_convert_document_to_image from html format
49
+ # Convert the HTML document from the storage by its name to the specified image format.
50
+ #
51
+ # @param name Document name.
52
+ # @param out_format Resulting image format (jpeg, png, bmp, tiff, gif).
53
+ # @param [Hash] opts the optional parameters
54
+ # @option opts [Integer] :width Resulting image width.
55
+ # @option opts [Integer] :height Resulting image height.
56
+ # @option opts [Integer] :left_margin Left resulting image margin.
57
+ # @option opts [Integer] :right_margin Right resulting image margin.
58
+ # @option opts [Integer] :top_margin Top resulting image margin.
59
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
60
+ # @option opts [Integer] :resolution Resolution of resulting image.
61
+ # @option opts [String] :folder The source document folder.
62
+ # @option opts [String] :storage The source document storage.
63
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
64
+ describe 'get_convert_html_to_image test' do
65
+ name = "test1.html"
66
+ opts = {
67
+ width: 800,
68
+ height: 1000,
69
+ left_margin: 30,
70
+ right_margin: 30,
71
+ top_margin: 50,
72
+ bottom_margin: 50,
73
+ resolution: 300,
74
+ folder: "HtmlTestDoc",
75
+ storage: nil
76
+ }
77
+
78
+ # Upload file to server
79
+ upload_file_helper(name)
80
+
81
+ it "Convert html to jpeg" do
82
+ out_format = "jpeg"
83
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
84
+
85
+ expect(answer).to be_an_instance_of Hash
86
+ expect(answer[:file]).to be_an_instance_of File
87
+ expect(answer[:status]).to eql(200)
88
+
89
+ # Save to test dir
90
+ save_to_test_dir(answer[:file], "Convert_get_html.jpeg")
91
+ end
92
+
93
+ it "Convert html to png" do
94
+ out_format = "png"
95
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
96
+
97
+ expect(answer).to be_an_instance_of Hash
98
+ expect(answer[:file]).to be_an_instance_of File
99
+ expect(answer[:status]).to eql(200)
100
+
101
+ # Save to test dir
102
+ save_to_test_dir(answer[:file], "Convert_get_html.png")
103
+ end
104
+
105
+ it "Convert html to bmp" do
106
+ out_format = "bmp"
107
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
108
+
109
+ expect(answer).to be_an_instance_of Hash
110
+ expect(answer[:file]).to be_an_instance_of File
111
+ expect(answer[:status]).to eql(200)
112
+
113
+ # Save to test dir
114
+ save_to_test_dir(answer[:file], "Convert_get_html.bmp")
115
+ end
116
+
117
+ it "Convert html to tiff" do
118
+ out_format = "tiff"
119
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
120
+
121
+ expect(answer).to be_an_instance_of Hash
122
+ expect(answer[:file]).to be_an_instance_of File
123
+ expect(answer[:status]).to eql(200)
124
+
125
+ # Save to test dir
126
+ save_to_test_dir(answer[:file], "Convert_get_html.tiff")
127
+ end
128
+
129
+ it "Convert html to gif" do
130
+ out_format = "gif"
131
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
132
+
133
+ expect(answer).to be_an_instance_of Hash
134
+ expect(answer[:file]).to be_an_instance_of File
135
+ expect(answer[:status]).to eql(200)
136
+
137
+ # Save to test dir
138
+ save_to_test_dir(answer[:file], "Convert_get_html.gif")
139
+ end
140
+ end
141
+
142
+ # unit tests for get_convert_document_to_image from epub format
143
+ # Convert the EPUB document from the storage by its name to the specified image format.
144
+ #
145
+ # @param name Document name.
146
+ # @param out_format Resulting image format (jpeg, png, bmp, tiff, gif).
147
+ # @param [Hash] opts the optional parameters
148
+ # @option opts [Integer] :width Resulting image width.
149
+ # @option opts [Integer] :height Resulting image height.
150
+ # @option opts [Integer] :left_margin Left resulting image margin.
151
+ # @option opts [Integer] :right_margin Right resulting image margin.
152
+ # @option opts [Integer] :top_margin Top resulting image margin.
153
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
154
+ # @option opts [Integer] :resolution Resolution of resulting image.
155
+ # @option opts [String] :folder The source document folder.
156
+ # @option opts [String] :storage The source document storage.
157
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
158
+ describe 'get_convert_epub_to_image test' do
159
+ name = "georgia.epub"
160
+ opts = {
161
+ width: 800,
162
+ height: 1000,
163
+ left_margin: 30,
164
+ right_margin: 30,
165
+ top_margin: 50,
166
+ bottom_margin: 50,
167
+ resolution: 300,
168
+ folder: "HtmlTestDoc",
169
+ storage: nil
170
+ }
171
+ # Upload file to server
172
+ upload_file_helper(name)
173
+
174
+ it "Convert epub to jpeg" do
175
+ out_format = "jpeg"
176
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
177
+
178
+ expect(answer).to be_an_instance_of Hash
179
+ expect(answer[:file]).to be_an_instance_of File
180
+ expect(answer[:status]).to eql(200)
181
+
182
+ # Save to test dir
183
+ save_to_test_dir(answer[:file], "Convert_get_epub_jpeg.zip")
184
+ end
185
+
186
+ it "Convert epub to png" do
187
+ out_format = "png"
188
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
189
+
190
+ expect(answer).to be_an_instance_of Hash
191
+ expect(answer[:file]).to be_an_instance_of File
192
+ expect(answer[:status]).to eql(200)
193
+
194
+ # Save to test dir
195
+ save_to_test_dir(answer[:file], "Convert_get_epub_png.zip")
196
+ end
197
+
198
+ it "Convert epub to bmp" do
199
+ out_format = "bmp"
200
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
201
+
202
+ expect(answer).to be_an_instance_of Hash
203
+ expect(answer[:file]).to be_an_instance_of File
204
+ expect(answer[:status]).to eql(200)
205
+
206
+ # Save to test dir
207
+ save_to_test_dir(answer[:file], "Convert_get_epub_bmp.zip")
208
+ end
209
+
210
+ it "Convert epub to tiff" do
211
+ out_format = "tiff"
212
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
213
+
214
+ expect(answer).to be_an_instance_of Hash
215
+ expect(answer[:file]).to be_an_instance_of File
216
+ expect(answer[:status]).to eql(200)
217
+
218
+ # Save to test dir
219
+ save_to_test_dir(answer[:file], "Convert_get_epub_tiff.zip")
220
+ end
221
+
222
+ it "Convert epub to gif" do
223
+ out_format = "gif"
224
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
225
+
226
+ expect(answer).to be_an_instance_of Hash
227
+ expect(answer[:file]).to be_an_instance_of File
228
+ expect(answer[:status]).to eql(200)
229
+
230
+ # Save to test dir
231
+ save_to_test_dir(answer[:file], "Convert_get_epub_gif.zip")
232
+ end
233
+ end
234
+
235
+ # unit tests for get_convert_document_to_image from svg format
236
+ # Convert the SVG document from the storage by its name to the specified image format.
237
+ #
238
+ # @param name Document name.
239
+ # @param out_format Resulting image format (jpeg, png, bmp, tiff, gif).
240
+ # @param [Hash] opts the optional parameters
241
+ # @option opts [Integer] :width Resulting image width.
242
+ # @option opts [Integer] :height Resulting image height.
243
+ # @option opts [Integer] :left_margin Left resulting image margin.
244
+ # @option opts [Integer] :right_margin Right resulting image margin.
245
+ # @option opts [Integer] :top_margin Top resulting image margin.
246
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
247
+ # @option opts [Integer] :resolution Resolution of resulting image.
248
+ # @option opts [String] :folder The source document folder.
249
+ # @option opts [String] :storage The source document storage.
250
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
251
+ describe 'get_convert_svg_to_image test' do
252
+ name = "Map-World.svg"
253
+ opts = {
254
+ width: 800,
255
+ height: 1000,
256
+ left_margin: 30,
257
+ right_margin: 30,
258
+ top_margin: 50,
259
+ bottom_margin: 50,
260
+ resolution: 300,
261
+ folder: "HtmlTestDoc",
262
+ storage: nil
263
+ }
264
+
265
+ # Upload file to server
266
+ upload_file_helper(name)
267
+
268
+ it "Convert svg to jpeg" do
269
+ out_format = "jpeg"
270
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
271
+
272
+ expect(answer).to be_an_instance_of Hash
273
+ expect(answer[:file]).to be_an_instance_of File
274
+ expect(answer[:status]).to eql(200)
275
+
276
+ # Save to test dir
277
+ save_to_test_dir(answer[:file], "Convert_get_svg.jpeg")
278
+ end
279
+
280
+ it "Convert svg to png" do
281
+ out_format = "png"
282
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
283
+
284
+ expect(answer).to be_an_instance_of Hash
285
+ expect(answer[:file]).to be_an_instance_of File
286
+ expect(answer[:status]).to eql(200)
287
+
288
+ # Save to test dir
289
+ save_to_test_dir(answer[:file], "Convert_get_svg.png")
290
+ end
291
+
292
+ it "Convert svg to bmp" do
293
+ out_format = "bmp"
294
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
295
+
296
+ expect(answer).to be_an_instance_of Hash
297
+ expect(answer[:file]).to be_an_instance_of File
298
+ expect(answer[:status]).to eql(200)
299
+
300
+ # Save to test dir
301
+ save_to_test_dir(answer[:file], "Convert_get_svg.bmp")
302
+ end
303
+
304
+ it "Convert svg to tiff" do
305
+ out_format = "tiff"
306
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
307
+
308
+ expect(answer).to be_an_instance_of Hash
309
+ expect(answer[:file]).to be_an_instance_of File
310
+ expect(answer[:status]).to eql(200)
311
+
312
+ # Save to test dir
313
+ save_to_test_dir(answer[:file], "Convert_get_svg.tiff")
314
+ end
315
+
316
+ it "Convert svg to gif" do
317
+ out_format = "gif"
318
+ answer = @instance.get_convert_document_to_image(name, out_format, opts)
319
+
320
+ expect(answer).to be_an_instance_of Hash
321
+ expect(answer[:file]).to be_an_instance_of File
322
+ expect(answer[:status]).to eql(200)
323
+
324
+ # Save to test dir
325
+ save_to_test_dir(answer[:file], "Convert_get_svg.gif")
326
+ end
327
+ end
328
+
329
+ # unit tests for get_convert_document_to_image_by_url
330
+ # Convert the HTML page from the web by its URL to the specified image format.
331
+ #
332
+ # @param source_url Source page URL.
333
+ # @param out_format Resulting image format.
334
+ # @param [Hash] opts the optional parameters
335
+ # @option opts [Integer] :width Resulting image width.
336
+ # @option opts [Integer] :height Resulting image height.
337
+ # @option opts [Integer] :left_margin Left resulting image margin.
338
+ # @option opts [Integer] :right_margin Right resulting image margin.
339
+ # @option opts [Integer] :top_margin Top resulting image margin.
340
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
341
+ # @option opts [Integer] :resolution Resolution of resulting image.
342
+ # @option opts [String] :folder The document folder.
343
+ # @option opts [String] :storage The document storage.
344
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
345
+ describe 'get_convert_html_to_image_by_url test' do
346
+ source_url = "https://stallman.org/articles/anonymous-payments-thru-phones.html"
347
+ opts = {
348
+ width: 800,
349
+ height: 1000,
350
+ left_margin: 30,
351
+ right_margin: 30,
352
+ top_margin: 50,
353
+ bottom_margin: 50,
354
+ resolution: 300,
355
+ folder: "HtmlTestDoc",
356
+ storage: nil
357
+ }
358
+
359
+ it "Convert url to jpeg" do
360
+ out_format = "jpeg"
361
+ answer = @instance.get_convert_document_to_image_by_url(source_url, out_format, opts)
362
+
363
+ expect(answer).to be_an_instance_of Hash
364
+ expect(answer[:file]).to be_an_instance_of File
365
+ expect(answer[:status]).to eql(200)
366
+
367
+ # Save to test dir
368
+ save_to_test_dir(answer[:file], "Convert_get_url.jpeg")
369
+ end
370
+
371
+ it "Convert url to png" do
372
+ out_format = "png"
373
+ answer = @instance.get_convert_document_to_image_by_url(source_url, out_format, opts)
374
+
375
+ expect(answer).to be_an_instance_of Hash
376
+ expect(answer[:file]).to be_an_instance_of File
377
+ expect(answer[:status]).to eql(200)
378
+
379
+ # Save to test dir
380
+ save_to_test_dir(answer[:file], "Convert_get_url.png")
381
+ end
382
+
383
+ it "Convert url to bmp" do
384
+ out_format = "bmp"
385
+ answer = @instance.get_convert_document_to_image_by_url(source_url, out_format, opts)
386
+
387
+ expect(answer).to be_an_instance_of Hash
388
+ expect(answer[:file]).to be_an_instance_of File
389
+ expect(answer[:status]).to eql(200)
390
+
391
+ # Save to test dir
392
+ save_to_test_dir(answer[:file], "Convert_get_url.bmp")
393
+ end
394
+
395
+ it "Convert url to tiff" do
396
+ out_format = "tiff"
397
+ answer = @instance.get_convert_document_to_image_by_url(source_url, out_format, opts)
398
+
399
+ expect(answer).to be_an_instance_of Hash
400
+ expect(answer[:file]).to be_an_instance_of File
401
+ expect(answer[:status]).to eql(200)
402
+
403
+ # Save to test dir
404
+ save_to_test_dir(answer[:file], "Convert_get_url.tiff")
405
+ end
406
+
407
+ it "Convert url to gif" do
408
+ out_format = "gif"
409
+ answer = @instance.get_convert_document_to_image_by_url(source_url, out_format, opts)
410
+
411
+ expect(answer).to be_an_instance_of Hash
412
+ expect(answer[:file]).to be_an_instance_of File
413
+ expect(answer[:status]).to eql(200)
414
+
415
+ # Save to test dir
416
+ save_to_test_dir(answer[:file], "Convert_get_url.gif")
417
+ end
418
+ end
419
+
420
+ # unit tests for get_convert_document_to_pdf from html format
421
+ # Convert the HTML document from the storage by its name to PDF.
422
+ #
423
+ # @param name Document name.
424
+ # @param [Hash] opts the optional parameters
425
+ # @option opts [Integer] :width Resulting image width.
426
+ # @option opts [Integer] :height Resulting image height.
427
+ # @option opts [Integer] :left_margin Left resulting image margin.
428
+ # @option opts [Integer] :right_margin Right resulting image margin.
429
+ # @option opts [Integer] :top_margin Top resulting image margin.
430
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
431
+ # @option opts [String] :folder The document folder.
432
+ # @option opts [String] :storage The document storage.
433
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
434
+ describe 'get_convert_html_to_pdf test' do
435
+ it "Convert html to pdf" do
436
+ name = "test1.html"
437
+ opts = {
438
+ width: 800,
439
+ height: 1000,
440
+ left_margin: 30,
441
+ right_margin: 30,
442
+ top_margin: 50,
443
+ bottom_margin: 50,
444
+ folder: "HtmlTestDoc",
445
+ storage: nil
446
+ }
447
+
448
+ # Upload file to server
449
+ res = upload_file_helper(name)
450
+ expect(res.uploaded.length).to eql(1)
451
+ expect(res.errors.length).to eql(0)
452
+
453
+ answer = @instance.get_convert_document_to_pdf(name, opts)
454
+
455
+ expect(answer).to be_an_instance_of Hash
456
+ expect(answer[:file]).to be_an_instance_of File
457
+ expect(answer[:status]).to eql(200)
458
+
459
+ # Save to test dir
460
+ save_to_test_dir(answer[:file], "Convert_get_html.pdf")
461
+ end
462
+ end
463
+
464
+ # unit tests for get_convert_document_to_pdf from epub format
465
+ # Convert the EPUB document from the storage by its name to PDF.
466
+ #
467
+ # @param name Document name.
468
+ # @param [Hash] opts the optional parameters
469
+ # @option opts [Integer] :width Resulting image width.
470
+ # @option opts [Integer] :height Resulting image height.
471
+ # @option opts [Integer] :left_margin Left resulting image margin.
472
+ # @option opts [Integer] :right_margin Right resulting image margin.
473
+ # @option opts [Integer] :top_margin Top resulting image margin.
474
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
475
+ # @option opts [String] :folder The document folder.
476
+ # @option opts [String] :storage The document storage.
477
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
478
+ describe 'get_convert_epub_to_pdf test' do
479
+ it "Convert epub to pdf" do
480
+ name = "georgia.epub"
481
+ opts = {
482
+ width: 800,
483
+ height: 1000,
484
+ left_margin: 30,
485
+ right_margin: 30,
486
+ top_margin: 50,
487
+ bottom_margin: 50,
488
+ folder: "HtmlTestDoc",
489
+ storage: nil
490
+ }
491
+
492
+ # Upload file to server
493
+ res = upload_file_helper(name)
494
+ expect(res.uploaded.length).to eql(1)
495
+ expect(res.errors.length).to eql(0)
496
+
497
+ answer = @instance.get_convert_document_to_pdf(name, opts)
498
+
499
+ expect(answer).to be_an_instance_of Hash
500
+ expect(answer[:file]).to be_an_instance_of File
501
+ expect(answer[:status]).to eql(200)
502
+
503
+ # Save to test dir
504
+ save_to_test_dir(answer[:file], "Convert_get_epub.pdf")
505
+ end
506
+ end
507
+
508
+ # unit tests for get_convert_document_to_pdf from svg format
509
+ # Convert the SVG document from the storage by its name to PDF.
510
+ #
511
+ # @param name Document name.
512
+ # @param [Hash] opts the optional parameters
513
+ # @option opts [Integer] :width Resulting image width.
514
+ # @option opts [Integer] :height Resulting image height.
515
+ # @option opts [Integer] :left_margin Left resulting image margin.
516
+ # @option opts [Integer] :right_margin Right resulting image margin.
517
+ # @option opts [Integer] :top_margin Top resulting image margin.
518
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
519
+ # @option opts [String] :folder The document folder.
520
+ # @option opts [String] :storage The document storage.
521
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
522
+ describe 'get_convert_svg_to_pdf test' do
523
+ it "Convert svg to pdf" do
524
+ name = "Map-World.svg"
525
+ opts = {
526
+ width: 800,
527
+ height: 1000,
528
+ left_margin: 30,
529
+ right_margin: 30,
530
+ top_margin: 50,
531
+ bottom_margin: 50,
532
+ folder: "HtmlTestDoc",
533
+ storage: nil
534
+ }
535
+
536
+ # Upload file to server
537
+ res = upload_file_helper(name)
538
+ expect(res.uploaded.length).to eql(1)
539
+ expect(res.errors.length).to eql(0)
540
+
541
+ answer = @instance.get_convert_document_to_pdf(name, opts)
542
+
543
+ expect(answer).to be_an_instance_of Hash
544
+ expect(answer[:file]).to be_an_instance_of File
545
+ expect(answer[:status]).to eql(200)
546
+
547
+ # Save to test dir
548
+ save_to_test_dir(answer[:file], "Convert_get_svg.pdf")
549
+ end
550
+ end
551
+
552
+ # unit tests for get_convert_document_to_pdf_by_url
553
+ # Convert the HTML page from the web by its URL to PDF.
554
+ #
555
+ # @param source_url Source page URL.
556
+ # @param [Hash] opts the optional parameters
557
+ # @option opts [Integer] :width Resulting image width.
558
+ # @option opts [Integer] :height Resulting image height.
559
+ # @option opts [Integer] :left_margin Left resulting image margin.
560
+ # @option opts [Integer] :right_margin Right resulting image margin.
561
+ # @option opts [Integer] :top_margin Top resulting image margin.
562
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
563
+ # @option opts [String] :folder The document folder.
564
+ # @option opts [String] :storage The document storage.
565
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
566
+ describe 'get_convert_html_to_pdf_by_url test' do
567
+ it "Convert url to pdf" do
568
+ source_url = "https://stallman.org/articles/anonymous-payments-thru-phones.html"
569
+ opts = {
570
+ width: 800,
571
+ height: 1000,
572
+ left_margin: 30,
573
+ right_margin: 30,
574
+ top_margin: 50,
575
+ bottom_margin: 50,
576
+ folder: "HtmlTestDoc",
577
+ storage: nil
578
+ }
579
+
580
+ answer = @instance.get_convert_document_to_pdf_by_url(source_url, opts)
581
+
582
+ expect(answer).to be_an_instance_of Hash
583
+ expect(answer[:file]).to be_an_instance_of File
584
+ expect(answer[:status]).to eql(200)
585
+
586
+ # Save to test dir
587
+ save_to_test_dir(answer[:file], "Convert_get_url.pdf")
588
+ end
589
+ end
590
+
591
+ # unit tests for get_convert_document_to_xps from html format
592
+ # Convert the HTML document from the storage by its name to XPS.
593
+ #
594
+ # @param name Document name.
595
+ # @param [Hash] opts the optional parameters
596
+ # @option opts [Integer] :width Resulting image width.
597
+ # @option opts [Integer] :height Resulting image height.
598
+ # @option opts [Integer] :left_margin Left resulting image margin.
599
+ # @option opts [Integer] :right_margin Right resulting image margin.
600
+ # @option opts [Integer] :top_margin Top resulting image margin.
601
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
602
+ # @option opts [String] :folder The document folder.
603
+ # @option opts [String] :storage The document storage.
604
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
605
+ describe 'get_convert_html_to_xps test' do
606
+ it "Convert html to xps" do
607
+ name = "test1.html"
608
+ opts = {
609
+ width: 800,
610
+ height: 1000,
611
+ left_margin: 30,
612
+ right_margin: 30,
613
+ top_margin: 50,
614
+ bottom_margin: 50,
615
+ folder: "HtmlTestDoc",
616
+ storage: nil
617
+ }
618
+
619
+ # Upload file to server
620
+ res = upload_file_helper(name)
621
+ expect(res.uploaded.length).to eql(1)
622
+ expect(res.errors.length).to eql(0)
623
+
624
+ answer = @instance.get_convert_document_to_xps(name, opts)
625
+
626
+ expect(answer).to be_an_instance_of Hash
627
+ expect(answer[:file]).to be_an_instance_of File
628
+ expect(answer[:status]).to eql(200)
629
+
630
+ # Save to test dir
631
+ save_to_test_dir(answer[:file], "Convert_get_html.xps")
632
+ end
633
+ end
634
+
635
+ # unit tests for get_convert_document_to_xps from epub format
636
+ # Convert the EPUB document from the storage by its name to XPS.
637
+ #
638
+ # @param name Document name.
639
+ # @param [Hash] opts the optional parameters
640
+ # @option opts [Integer] :width Resulting image width.
641
+ # @option opts [Integer] :height Resulting image height.
642
+ # @option opts [Integer] :left_margin Left resulting image margin.
643
+ # @option opts [Integer] :right_margin Right resulting image margin.
644
+ # @option opts [Integer] :top_margin Top resulting image margin.
645
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
646
+ # @option opts [String] :folder The document folder.
647
+ # @option opts [String] :storage The document storage.
648
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
649
+ describe 'get_convert_epub_to_xps test' do
650
+ it "Convert epnb to xps" do
651
+ name = "georgia.epub"
652
+ opts = {
653
+ width: 800,
654
+ height: 1000,
655
+ left_margin: 30,
656
+ right_margin: 30,
657
+ top_margin: 50,
658
+ bottom_margin: 50,
659
+ folder: "HtmlTestDoc",
660
+ storage: nil
661
+ }
662
+
663
+ # Upload file to server
664
+ res = upload_file_helper(name)
665
+ expect(res.uploaded.length).to eql(1)
666
+ expect(res.errors.length).to eql(0)
667
+
668
+ answer = @instance.get_convert_document_to_xps(name, opts)
669
+
670
+ expect(answer).to be_an_instance_of Hash
671
+ expect(answer[:file]).to be_an_instance_of File
672
+ expect(answer[:status]).to eql(200)
673
+
674
+ # Save to test dir
675
+ save_to_test_dir(answer[:file], "Convert_get_epub.xps")
676
+ end
677
+ end
678
+
679
+ # unit tests for get_convert_document_to_xps from svg format
680
+ # Convert the SVG document from the storage by its name to XPS.
681
+ #
682
+ # @param name Document name.
683
+ # @param [Hash] opts the optional parameters
684
+ # @option opts [Integer] :width Resulting image width.
685
+ # @option opts [Integer] :height Resulting image height.
686
+ # @option opts [Integer] :left_margin Left resulting image margin.
687
+ # @option opts [Integer] :right_margin Right resulting image margin.
688
+ # @option opts [Integer] :top_margin Top resulting image margin.
689
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
690
+ # @option opts [String] :folder The document folder.
691
+ # @option opts [String] :storage The document storage.
692
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
693
+ describe 'get_convert_svg_to_xps test' do
694
+ it "Convert svg to xps" do
695
+ name = "Map-World.svg"
696
+ opts = {
697
+ width: 800,
698
+ height: 1000,
699
+ left_margin: 30,
700
+ right_margin: 30,
701
+ top_margin: 50,
702
+ bottom_margin: 50,
703
+ folder: "HtmlTestDoc",
704
+ storage: nil
705
+ }
706
+
707
+ # Upload file to server
708
+ res = upload_file_helper(name)
709
+ expect(res.uploaded.length).to eql(1)
710
+ expect(res.errors.length).to eql(0)
711
+
712
+ answer = @instance.get_convert_document_to_xps(name, opts)
713
+
714
+ expect(answer).to be_an_instance_of Hash
715
+ expect(answer[:file]).to be_an_instance_of File
716
+ expect(answer[:status]).to eql(200)
717
+
718
+ # Save to test dir
719
+ save_to_test_dir(answer[:file], "Convert_get_svg.xps")
720
+ end
721
+ end
722
+
723
+ # unit tests for get_convert_document_to_xps_by_url
724
+ # Convert the HTML page from the web by its URL to XPS.
725
+ #
726
+ # @param source_url Source page URL.
727
+ # @param [Hash] opts the optional parameters
728
+ # @option opts [Integer] :width Resulting image width.
729
+ # @option opts [Integer] :height Resulting image height.
730
+ # @option opts [Integer] :left_margin Left resulting image margin.
731
+ # @option opts [Integer] :right_margin Right resulting image margin.
732
+ # @option opts [Integer] :top_margin Top resulting image margin.
733
+ # @option opts [Integer] :bottom_margin Bottom resulting image margin.
734
+ # @option opts [String] :folder The document folder.
735
+ # @option opts [String] :storage The document storage.
736
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
737
+ describe 'get_convert_document_to_xps_by_url test' do
738
+ it "Convert url to xps" do
739
+ source_url = "https://stallman.org/articles/anonymous-payments-thru-phones.html"
740
+ opts = {
741
+ width: 800,
742
+ height: 1000,
743
+ left_margin: 30,
744
+ right_margin: 30,
745
+ top_margin: 50,
746
+ bottom_margin: 50,
747
+ folder: "HtmlTestDoc",
748
+ storage: nil
749
+ }
750
+
751
+ answer = @instance.get_convert_document_to_xps_by_url(source_url, opts)
752
+
753
+ expect(answer).to be_an_instance_of Hash
754
+ expect(answer[:file]).to be_an_instance_of File
755
+ expect(answer[:status]).to eql(200)
756
+
757
+ # Save to test dir
758
+ save_to_test_dir(answer[:file], "Convert_html_url.xps")
759
+ end
760
+ end
761
+
762
+ # unit tests for post_convert_document_in_request_to_image from html format
763
+ # Converts the HTML document (in request content) to the specified image format and uploads resulting file to storage.
764
+ #
765
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
766
+ # @param out_format (jpeg, png, bmp, tiff, gif).
767
+ # @param file A file to be converted (html, epub, svg).
768
+ # @param [Hash] opts the optional parameters
769
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
770
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
771
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
772
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
773
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
774
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
775
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
776
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
777
+ describe 'post_convert_html_in_request_to_image test' do
778
+ file = File.realpath(__dir__ + '/../../testdata/test1.html')
779
+ opts = {
780
+ width: 800,
781
+ height: 1000,
782
+ left_margin: 30,
783
+ right_margin: 30,
784
+ top_margin: 50,
785
+ bottom_margin: 50,
786
+ resolution: 300
787
+ }
788
+
789
+ it "Upload and convert html to jpeg" do
790
+ name = "postHtmlToJpegInReq.jpeg"
791
+ out_path = "HtmlTestDoc/" + name
792
+ out_format = "jpeg"
793
+
794
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
795
+
796
+ expect(answer[:status]).to eql(200)
797
+
798
+ #Download converted file from storage
799
+ res = download_file_helper(name)
800
+ expect(res).to be_an_instance_of File
801
+
802
+ #Move to test folder
803
+ save_to_test_dir(res, name)
804
+ end
805
+
806
+ it "Upload and convert html to png" do
807
+ name = "postHtmlToPngInReq.png"
808
+ out_path = "HtmlTestDoc/" + name
809
+ out_format = "png"
810
+
811
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
812
+
813
+ expect(answer[:status]).to eql(200)
814
+
815
+ #Download converted file from storage
816
+ res = download_file_helper(name)
817
+ expect(res).to be_an_instance_of File
818
+
819
+ #Move to test folder
820
+ save_to_test_dir(res, name)
821
+ end
822
+
823
+ it "Upload and convert html to bmp" do
824
+ name = "postHtmlToBmpInReq.bmp"
825
+ out_path = "HtmlTestDoc/" + name
826
+ out_format = "bmp"
827
+
828
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
829
+
830
+ expect(answer[:status]).to eql(200)
831
+
832
+ #Download converted file from storage
833
+ res = download_file_helper(name)
834
+ expect(res).to be_an_instance_of File
835
+
836
+ #Move to test folder
837
+ save_to_test_dir(res, name)
838
+ end
839
+
840
+ it "Upload and convert html to tiff" do
841
+ name = "postHtmlToTiffInReq.tiff"
842
+ out_path = "HtmlTestDoc/" + name
843
+ out_format = "tiff"
844
+
845
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
846
+
847
+ expect(answer[:status]).to eql(200)
848
+
849
+ #Download converted file from storage
850
+ res = download_file_helper(name)
851
+ expect(res).to be_an_instance_of File
852
+
853
+ #Move to test folder
854
+ save_to_test_dir(res, name)
855
+ end
856
+
857
+ it "Upload and convert html to gif" do
858
+ name = "postHtmlToGifInReq.gif"
859
+ out_path = "HtmlTestDoc/" + name
860
+ out_format = "gif"
861
+
862
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
863
+
864
+ expect(answer[:status]).to eql(200)
865
+
866
+ #Download converted file from storage
867
+ res = download_file_helper(name)
868
+ expect(res).to be_an_instance_of File
869
+
870
+ #Move to test folder
871
+ save_to_test_dir(res, name)
872
+ end
873
+ end
874
+
875
+ # unit tests for post_convert_document_in_request_to_image from epub format
876
+ # Converts the EPUB document (in request content) to the specified image format and uploads resulting file to storage.
877
+ #
878
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
879
+ # @param out_format (jpeg, png, bmp, tiff, gif).
880
+ # @param file A file to be converted (html, epub, svg).
881
+ # @param [Hash] opts the optional parameters
882
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
883
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
884
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
885
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
886
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
887
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
888
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
889
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
890
+ describe 'post_convert_epub_in_request_to_image test' do
891
+ file = File.realpath(__dir__ + '/../../testdata/georgia.epub')
892
+ opts = {
893
+ width: 800,
894
+ height: 1000,
895
+ left_margin: 30,
896
+ right_margin: 30,
897
+ top_margin: 50,
898
+ bottom_margin: 50,
899
+ resolution: 300
900
+ }
901
+
902
+ it "Upload and convert epub to jpeg" do
903
+ name = "postEpubToJpegInReq.zip"
904
+ out_path = "HtmlTestDoc/" + name
905
+ out_format = "jpeg"
906
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
907
+
908
+ expect(answer[:status]).to eql(200)
909
+
910
+ #Download converted file from storage
911
+ res = download_file_helper(name)
912
+ expect(res).to be_an_instance_of File
913
+
914
+ #Move to test folder
915
+ save_to_test_dir(res, name)
916
+ end
917
+
918
+ it "Upload and convert epub to png" do
919
+ name = "postEpubToPngInReq.zip"
920
+ out_path = "HtmlTestDoc/" + name
921
+ out_format = "png"
922
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
923
+
924
+ expect(answer[:status]).to eql(200)
925
+
926
+ #Download converted file from storage
927
+ res = download_file_helper(name)
928
+ expect(res).to be_an_instance_of File
929
+
930
+ #Move to test folder
931
+ save_to_test_dir(res, name)
932
+ end
933
+
934
+ it "Upload and convert epub to bmp" do
935
+ name = "postEpubToBmpInReq.zip"
936
+ out_path = "HtmlTestDoc/" + name
937
+ out_format = "bmp"
938
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
939
+
940
+ expect(answer[:status]).to eql(200)
941
+
942
+ #Download converted file from storage
943
+ res = download_file_helper(name)
944
+ expect(res).to be_an_instance_of File
945
+
946
+ #Move to test folder
947
+ save_to_test_dir(res, name)
948
+ end
949
+
950
+ it "Upload and convert epub to tiff" do
951
+ name = "postEpubToTiffInReq.zip"
952
+ out_path = "HtmlTestDoc/" + name
953
+ out_format = "tiff"
954
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
955
+
956
+ expect(answer[:status]).to eql(200)
957
+
958
+ #Download converted file from storage
959
+ res = download_file_helper(name)
960
+ expect(res).to be_an_instance_of File
961
+
962
+ #Move to test folder
963
+ save_to_test_dir(res, name)
964
+ end
965
+
966
+ it "Upload and convert epub to gif" do
967
+ name = "postEpubToGifInReq.zip"
968
+ out_path = "HtmlTestDoc/" + name
969
+ out_format = "gif"
970
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
971
+
972
+ expect(answer[:status]).to eql(200)
973
+
974
+ #Download converted file from storage
975
+ res = download_file_helper(name)
976
+ expect(res).to be_an_instance_of File
977
+
978
+ #Move to test folder
979
+ save_to_test_dir(res, name)
980
+ end
981
+ end
982
+
983
+ # unit tests for post_convert_document_in_request_to_image from svg format
984
+ # Converts the SVG document (in request content) to the specified image format and uploads resulting file to storage.
985
+ #
986
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
987
+ # @param out_format (jpeg, png, bmp, tiff, gif).
988
+ # @param file A file to be converted (html, epub, svg).
989
+ # @param [Hash] opts the optional parameters
990
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
991
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
992
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
993
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
994
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
995
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
996
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
997
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
998
+ describe 'post_convert_svg_in_request_to_image test' do
999
+ file = File.realpath(__dir__ + '/../../testdata/Map-World.svg')
1000
+ opts = {
1001
+ width: 800,
1002
+ height: 1000,
1003
+ left_margin: 30,
1004
+ right_margin: 30,
1005
+ top_margin: 50,
1006
+ bottom_margin: 50,
1007
+ resolution: 300
1008
+ }
1009
+
1010
+ it "Upload and convert svg to jpeg" do
1011
+ name = "postSvgToJpegInReq.jpeg"
1012
+ out_path = "HtmlTestDoc/" + name
1013
+ out_format = "jpeg"
1014
+
1015
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
1016
+
1017
+ expect(answer[:status]).to eql(200)
1018
+
1019
+ #Download converted file from storage
1020
+ res = download_file_helper(name)
1021
+ expect(res).to be_an_instance_of File
1022
+
1023
+ #Move to test folder
1024
+ save_to_test_dir(res, name)
1025
+ end
1026
+
1027
+ it "Upload and convert svg to png" do
1028
+ name = "postSvgToPngInReq.png"
1029
+ out_path = "HtmlTestDoc/" + name
1030
+ out_format = "png"
1031
+
1032
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
1033
+
1034
+ expect(answer[:status]).to eql(200)
1035
+
1036
+ #Download converted file from storage
1037
+ res = download_file_helper(name)
1038
+ expect(res).to be_an_instance_of File
1039
+
1040
+ #Move to test folder
1041
+ save_to_test_dir(res, name)
1042
+ end
1043
+
1044
+ it "Upload and convert svg to bmp" do
1045
+ name = "postSvgToBmpInReq.bmp"
1046
+ out_path = "HtmlTestDoc/" + name
1047
+ out_format = "bmp"
1048
+
1049
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
1050
+
1051
+ expect(answer[:status]).to eql(200)
1052
+
1053
+ #Download converted file from storage
1054
+ res = download_file_helper(name)
1055
+ expect(res).to be_an_instance_of File
1056
+
1057
+ #Move to test folder
1058
+ save_to_test_dir(res, name)
1059
+ end
1060
+
1061
+ it "Upload and convert svg to tiff" do
1062
+ name = "postSvgToTiffInReq.tiff"
1063
+ out_path = "HtmlTestDoc/" + name
1064
+ out_format = "tiff"
1065
+
1066
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
1067
+
1068
+ expect(answer[:status]).to eql(200)
1069
+
1070
+ #Download converted file from storage
1071
+ res = download_file_helper(name)
1072
+ expect(res).to be_an_instance_of File
1073
+
1074
+ #Move to test folder
1075
+ save_to_test_dir(res, name)
1076
+ end
1077
+
1078
+ it "Upload and convert svg to gif" do
1079
+ name = "postSvgToGifInReq.gif"
1080
+ out_path = "HtmlTestDoc/" + name
1081
+ out_format = "gif"
1082
+
1083
+ answer = @instance.post_convert_document_in_request_to_image(out_path, out_format, file, opts)
1084
+
1085
+ expect(answer[:status]).to eql(200)
1086
+
1087
+ #Download converted file from storage
1088
+ res = download_file_helper(name)
1089
+ expect(res).to be_an_instance_of File
1090
+
1091
+ #Move to test folder
1092
+ save_to_test_dir(res, name)
1093
+ end
1094
+ end
1095
+
1096
+ # unit tests for post_convert_document_in_request_to_pdf from html format
1097
+ # Converts the HTML document (in request content) to PDF and uploads resulting file to storage.
1098
+ #
1099
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1100
+ # @param file A file to be converted.
1101
+ # @param [Hash] opts the optional parameters
1102
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1103
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1104
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1105
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1106
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1107
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1108
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1109
+ describe 'post_convert_html_in_request_to_pdf test' do
1110
+ it "Upload and convert html to pdf" do
1111
+ name = "postHtmlToPdfInReq.pdf"
1112
+ out_path = "HtmlTestDoc/" + name
1113
+ file = File.realpath(__dir__ + '/../../testdata/test1.html')
1114
+ opts = {
1115
+ width: 800,
1116
+ height: 1000,
1117
+ left_margin: 30,
1118
+ right_margin: 30,
1119
+ top_margin: 50,
1120
+ bottom_margin: 50
1121
+ }
1122
+
1123
+ answer = @instance.post_convert_document_in_request_to_pdf(out_path, file, opts)
1124
+
1125
+ expect(answer[:status]).to eql(200)
1126
+
1127
+ #Download converted file from storage
1128
+ res = download_file_helper(name)
1129
+ expect(res).to be_an_instance_of File
1130
+
1131
+ #Move to test folder
1132
+ save_to_test_dir(res, name)
1133
+ end
1134
+ end
1135
+
1136
+ # unit tests for post_convert_document_in_request_to_pdf from epub format
1137
+ # Converts the EPUB document (in request content) to PDF and uploads resulting file to storage.
1138
+ #
1139
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1140
+ # @param file A file to be converted.
1141
+ # @param [Hash] opts the optional parameters
1142
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1143
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1144
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1145
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1146
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1147
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1148
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1149
+ describe 'post_convert_epub_in_request_to_pdf test' do
1150
+ it "Upload and convert epub to pdf" do
1151
+ name = "postEpubToPdfInReq.pdf"
1152
+ out_path = "HtmlTestDoc/" + name
1153
+ file = File.realpath(__dir__ + '/../../testdata/georgia.epub')
1154
+ opts = {
1155
+ width: 800,
1156
+ height: 1000,
1157
+ left_margin: 30,
1158
+ right_margin: 30,
1159
+ top_margin: 50,
1160
+ bottom_margin: 50
1161
+ }
1162
+
1163
+ answer = @instance.post_convert_document_in_request_to_pdf(out_path, file, opts)
1164
+
1165
+ expect(answer[:status]).to eql(200)
1166
+
1167
+ #Download converted file from storage
1168
+ res = download_file_helper(name)
1169
+ expect(res).to be_an_instance_of File
1170
+
1171
+ #Move to test folder
1172
+ save_to_test_dir(res, name)
1173
+ end
1174
+ end
1175
+
1176
+ # unit tests for post_convert_document_in_request_to_pdf from svg format
1177
+ # Converts the SVG document (in request content) to PDF and uploads resulting file to storage.
1178
+ #
1179
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1180
+ # @param file A file to be converted.
1181
+ # @param [Hash] opts the optional parameters
1182
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1183
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1184
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1185
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1186
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1187
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1188
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1189
+ describe 'post_convert_svg_in_request_to_pdf test' do
1190
+ it "Upload and convert svg to pdf" do
1191
+ name = "postSvgToPdfInReq.pdf"
1192
+ out_path = "HtmlTestDoc/" + name
1193
+ file = File.realpath(__dir__ + '/../../testdata/Map-World.svg')
1194
+ opts = {
1195
+ width: 800,
1196
+ height: 1000,
1197
+ left_margin: 30,
1198
+ right_margin: 30,
1199
+ top_margin: 50,
1200
+ bottom_margin: 50
1201
+ }
1202
+
1203
+ answer = @instance.post_convert_document_in_request_to_pdf(out_path, file, opts)
1204
+
1205
+ expect(answer[:status]).to eql(200)
1206
+
1207
+ #Download converted file from storage
1208
+ res = download_file_helper(name)
1209
+ expect(res).to be_an_instance_of File
1210
+
1211
+ #Move to test folder
1212
+ save_to_test_dir(res, name)
1213
+ end
1214
+ end
1215
+
1216
+ # unit tests for post_convert_document_in_request_to_xps from html format
1217
+ # Converts the HTML document (in request content) to XPS and uploads resulting file to storage.
1218
+ #
1219
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1220
+ # @param file A file to be converted.
1221
+ # @param [Hash] opts the optional parameters
1222
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1223
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1224
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1225
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1226
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1227
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1228
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1229
+ describe 'post_convert_html_in_request_to_xps test' do
1230
+ it "Upload and convert html to xps" do
1231
+ name = "postHtmlToXpsInReq.xps"
1232
+ out_path = "HtmlTestDoc/" + name
1233
+ file = File.realpath(__dir__ + '/../../testdata/test1.html')
1234
+ opts = {
1235
+ width: 800,
1236
+ height: 1000,
1237
+ left_margin: 30,
1238
+ right_margin: 30,
1239
+ top_margin: 50,
1240
+ bottom_margin: 50
1241
+ }
1242
+
1243
+ answer = @instance.post_convert_document_in_request_to_xps(out_path, file, opts)
1244
+
1245
+ expect(answer[:status]).to eql(200)
1246
+
1247
+ #Download converted file from storage
1248
+ res = download_file_helper(name)
1249
+ expect(res).to be_an_instance_of File
1250
+
1251
+ #Move to test folder
1252
+ save_to_test_dir(res, name)
1253
+ end
1254
+ end
1255
+
1256
+ # unit tests for post_convert_document_in_request_to_xps from epub format
1257
+ # Converts the EPUB document (in request content) to XPS and uploads resulting file to storage.
1258
+ #
1259
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1260
+ # @param file A file to be converted.
1261
+ # @param [Hash] opts the optional parameters
1262
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1263
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1264
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1265
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1266
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1267
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1268
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1269
+ describe 'post_convert_epub_in_request_to_xps test' do
1270
+ it "Upload and convert epub to xps" do
1271
+ name = "postEpubToXpsInReq.xps"
1272
+ out_path = "HtmlTestDoc/" + name
1273
+ file = File.realpath(__dir__ + '/../../testdata/georgia.epub')
1274
+ opts = {
1275
+ width: 800,
1276
+ height: 1000,
1277
+ left_margin: 30,
1278
+ right_margin: 30,
1279
+ top_margin: 50,
1280
+ bottom_margin: 50
1281
+ }
1282
+
1283
+ answer = @instance.post_convert_document_in_request_to_xps(out_path, file, opts)
1284
+
1285
+ expect(answer[:status]).to eql(200)
1286
+
1287
+ #Download converted file from storage
1288
+ res = download_file_helper(name)
1289
+ expect(res).to be_an_instance_of File
1290
+
1291
+ #Move to test folder
1292
+ save_to_test_dir(res, name)
1293
+ end
1294
+ end
1295
+
1296
+ # unit tests for post_convert_document_in_request_to_xps from svg format
1297
+ # Converts the SVG document (in request content) to XPS and uploads resulting file to storage.
1298
+ #
1299
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1300
+ # @param file A file to be converted.
1301
+ # @param [Hash] opts the optional parameters
1302
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1303
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1304
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1305
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1306
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1307
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1308
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1309
+ describe 'post_convert_svg_in_request_to_xps test' do
1310
+ it "Upload and convert svg to xps" do
1311
+ name = "postSvgToXpsInReq.xps"
1312
+ out_path = "HtmlTestDoc/" + name
1313
+ file = File.realpath(__dir__ + '/../../testdata/Map-World.svg')
1314
+ opts = {
1315
+ width: 800,
1316
+ height: 1000,
1317
+ left_margin: 30,
1318
+ right_margin: 30,
1319
+ top_margin: 50,
1320
+ bottom_margin: 50
1321
+ }
1322
+
1323
+ answer = @instance.post_convert_document_in_request_to_xps(out_path, file, opts)
1324
+
1325
+ expect(answer[:status]).to eql(200)
1326
+
1327
+ #Download converted file from storage
1328
+ res = download_file_helper(name)
1329
+ expect(res).to be_an_instance_of File
1330
+
1331
+ #Move to test folder
1332
+ save_to_test_dir(res, name)
1333
+ end
1334
+ end
1335
+
1336
+ # unit tests for put_convert_document_to_image from html format
1337
+ # Converts the HTML document (located on storage) to the specified image format and uploads resulting file to storage.
1338
+ #
1339
+ # @param name Document name.
1340
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
1341
+ # @param out_format (jpeg, png, bmp, tiff, gif)
1342
+ # @param [Hash] opts the optional parameters
1343
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1344
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1345
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1346
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1347
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1348
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1349
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
1350
+ # @option opts [String] :folder The source document folder.
1351
+ # @option opts [String] :storage The source and resulting document storage.
1352
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1353
+ describe 'put_convert_html_to_image test' do
1354
+ # Already in the storage
1355
+ name = "test1.html"
1356
+ opts = {
1357
+ width: 800,
1358
+ height: 1000,
1359
+ left_margin: 30,
1360
+ right_margin: 30,
1361
+ top_margin: 50,
1362
+ bottom_margin: 50,
1363
+ resolution: 300,
1364
+ folder: "HtmlTestDoc",
1365
+ storage: nil
1366
+ }
1367
+
1368
+ it "Convert html to jpeg in storage" do
1369
+ result_name = "putHtmlToJpeg.jpeg"
1370
+ out_path = "HtmlTestDoc/" + result_name
1371
+ out_format = "jpeg"
1372
+
1373
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1374
+
1375
+ expect(answer[:status]).to eql(200)
1376
+
1377
+ #Download converted file from storage
1378
+ res = download_file_helper(result_name)
1379
+ expect(res).to be_an_instance_of File
1380
+
1381
+ #Move to test folder
1382
+ save_to_test_dir(res, result_name)
1383
+ end
1384
+
1385
+ it "Convert html to png in storage" do
1386
+ result_name = "putHtmlToPng.png"
1387
+ out_path = "HtmlTestDoc/" + result_name
1388
+ out_format = "png"
1389
+
1390
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1391
+
1392
+ expect(answer[:status]).to eql(200)
1393
+
1394
+ #Download converted file from storage
1395
+ res = download_file_helper(result_name)
1396
+ expect(res).to be_an_instance_of File
1397
+
1398
+ #Move to test folder
1399
+ save_to_test_dir(res, result_name)
1400
+ end
1401
+
1402
+ it "Convert html to bmp in storage" do
1403
+ result_name = "putHtmlToBmp.bmp"
1404
+ out_path = "HtmlTestDoc/" + result_name
1405
+ out_format = "bmp"
1406
+
1407
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1408
+
1409
+ expect(answer[:status]).to eql(200)
1410
+
1411
+ #Download converted file from storage
1412
+ res = download_file_helper(result_name)
1413
+ expect(res).to be_an_instance_of File
1414
+
1415
+ #Move to test folder
1416
+ save_to_test_dir(res, result_name)
1417
+ end
1418
+
1419
+ it "Convert html to tiff in storage" do
1420
+ result_name = "putHtmlToTiff.tiff"
1421
+ out_path = "HtmlTestDoc/" + result_name
1422
+ out_format = "tiff"
1423
+
1424
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1425
+
1426
+ expect(answer[:status]).to eql(200)
1427
+
1428
+ #Download converted file from storage
1429
+ res = download_file_helper(result_name)
1430
+ expect(res).to be_an_instance_of File
1431
+
1432
+ #Move to test folder
1433
+ save_to_test_dir(res, result_name)
1434
+ end
1435
+
1436
+ it "Convert html to gif in storage" do
1437
+ result_name = "putHtmlToGif.gif"
1438
+ out_path = "HtmlTestDoc/" + result_name
1439
+ out_format = "gif"
1440
+
1441
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1442
+
1443
+ expect(answer[:status]).to eql(200)
1444
+
1445
+ #Download converted file from storage
1446
+ res = download_file_helper(result_name)
1447
+ expect(res).to be_an_instance_of File
1448
+
1449
+ #Move to test folder
1450
+ save_to_test_dir(res, result_name)
1451
+ end
1452
+ end
1453
+
1454
+ # unit tests for put_convert_document_to_image from epub format
1455
+ # Converts the EPUB document (located on storage) to the specified image format and uploads resulting file to storage.
1456
+ #
1457
+ # @param name Document name.
1458
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
1459
+ # @param out_format (jpeg, png, bmp, tiff, gif)
1460
+ # @param [Hash] opts the optional parameters
1461
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1462
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1463
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1464
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1465
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1466
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1467
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
1468
+ # @option opts [String] :folder The source document folder.
1469
+ # @option opts [String] :storage The source and resulting document storage.
1470
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1471
+ describe 'put_convert_epub_to_image test' do
1472
+
1473
+ # Already in the storage
1474
+ name = "georgia.epub"
1475
+ opts = {
1476
+ width: 800,
1477
+ height: 1000,
1478
+ left_margin: 30,
1479
+ right_margin: 30,
1480
+ top_margin: 50,
1481
+ bottom_margin: 50,
1482
+ resolution: 300,
1483
+ folder: "HtmlTestDoc",
1484
+ storage: nil
1485
+ }
1486
+
1487
+ it "Convert epub to jpeg in storage" do
1488
+
1489
+ result_name = "putEpubToJpeg.zip"
1490
+ out_path = "HtmlTestDoc/" + result_name
1491
+ out_format = "jpeg"
1492
+
1493
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1494
+
1495
+ expect(answer[:status]).to eql(200)
1496
+
1497
+ #Download converted file from storage
1498
+ res = download_file_helper(result_name)
1499
+ expect(res).to be_an_instance_of File
1500
+
1501
+ #Move to test folder
1502
+ save_to_test_dir(res, result_name)
1503
+ end
1504
+
1505
+ it "Convert epub to png in storage" do
1506
+ result_name = "putEpubToPng.zip"
1507
+ out_path = "HtmlTestDoc/" + result_name
1508
+ out_format = "png"
1509
+
1510
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1511
+
1512
+ expect(answer[:status]).to eql(200)
1513
+
1514
+ #Download converted file from storage
1515
+ res = download_file_helper(result_name)
1516
+ expect(res).to be_an_instance_of File
1517
+
1518
+ #Move to test folder
1519
+ save_to_test_dir(res, result_name)
1520
+ end
1521
+
1522
+ it "Convert epub to bmp in storage" do
1523
+ result_name = "putEpubToBmp.zip"
1524
+ out_path = "HtmlTestDoc/" + result_name
1525
+ out_format = "bmp"
1526
+
1527
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1528
+
1529
+ expect(answer[:status]).to eql(200)
1530
+
1531
+ #Download converted file from storage
1532
+ res = download_file_helper(result_name)
1533
+ expect(res).to be_an_instance_of File
1534
+
1535
+ #Move to test folder
1536
+ save_to_test_dir(res, result_name)
1537
+ end
1538
+
1539
+ it "Convert epub to tiff in storage" do
1540
+ result_name = "putEpubToTiff.zip"
1541
+ out_path = "HtmlTestDoc/" + result_name
1542
+ out_format = "tiff"
1543
+
1544
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1545
+
1546
+ expect(answer[:status]).to eql(200)
1547
+
1548
+ #Download converted file from storage
1549
+ res = download_file_helper(result_name)
1550
+ expect(res).to be_an_instance_of File
1551
+
1552
+ #Move to test folder
1553
+ save_to_test_dir(res, result_name)
1554
+ end
1555
+
1556
+ it "Convert epub to gif in storage" do
1557
+ result_name = "putEpubToGif.zip"
1558
+ out_path = "HtmlTestDoc/" + result_name
1559
+ out_format = "gif"
1560
+
1561
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1562
+
1563
+ expect(answer[:status]).to eql(200)
1564
+
1565
+ #Download converted file from storage
1566
+ res = download_file_helper(result_name)
1567
+ expect(res).to be_an_instance_of File
1568
+
1569
+ #Move to test folder
1570
+ save_to_test_dir(res, result_name)
1571
+ end
1572
+ end
1573
+
1574
+ # unit tests for put_convert_document_to_image from svg format
1575
+ # Converts the SVG document (located on storage) to the specified image format and uploads resulting file to storage.
1576
+ #
1577
+ # @param name Document name.
1578
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.jpg)
1579
+ # @param out_format (jpeg, png, bmp, tiff, gif)
1580
+ # @param [Hash] opts the optional parameters
1581
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1582
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1583
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1584
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1585
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1586
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1587
+ # @option opts [Integer] :resolution Resolution of resulting image. Default is 96 dpi.
1588
+ # @option opts [String] :folder The source document folder.
1589
+ # @option opts [String] :storage The source and resulting document storage.
1590
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1591
+ describe 'put_convert_svg_to_image test' do
1592
+ # Already in the storage
1593
+ name = "Map-World.svg"
1594
+ opts = {
1595
+ width: 800,
1596
+ height: 1000,
1597
+ left_margin: 30,
1598
+ right_margin: 30,
1599
+ top_margin: 50,
1600
+ bottom_margin: 50,
1601
+ resolution: 300,
1602
+ folder: "HtmlTestDoc",
1603
+ storage: nil
1604
+ }
1605
+
1606
+ it "Convert svg to jpeg in storage" do
1607
+ result_name = "putSvgToJpeg.png"
1608
+ out_path = "HtmlTestDoc/" + result_name
1609
+ out_format = "jpeg"
1610
+
1611
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1612
+
1613
+ expect(answer[:status]).to eql(200)
1614
+
1615
+ #Download converted file from storage
1616
+ res = download_file_helper(result_name)
1617
+ expect(res).to be_an_instance_of File
1618
+
1619
+ #Move to test folder
1620
+ save_to_test_dir(res, result_name)
1621
+ end
1622
+
1623
+ it "Convert svg to png in storage" do
1624
+ result_name = "putSvgToPng.png"
1625
+ out_path = "HtmlTestDoc/" + result_name
1626
+ out_format = "png"
1627
+
1628
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1629
+
1630
+ expect(answer[:status]).to eql(200)
1631
+
1632
+ #Download converted file from storage
1633
+ res = download_file_helper(result_name)
1634
+ expect(res).to be_an_instance_of File
1635
+
1636
+ #Move to test folder
1637
+ save_to_test_dir(res, result_name)
1638
+ end
1639
+
1640
+ it "Convert svg to bmp in storage" do
1641
+ result_name = "putSvgToBmp.bmp"
1642
+ out_path = "HtmlTestDoc/" + result_name
1643
+ out_format = "bmp"
1644
+
1645
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1646
+
1647
+ expect(answer[:status]).to eql(200)
1648
+
1649
+ #Download converted file from storage
1650
+ res = download_file_helper(result_name)
1651
+ expect(res).to be_an_instance_of File
1652
+
1653
+ #Move to test folder
1654
+ save_to_test_dir(res, result_name)
1655
+ end
1656
+
1657
+ it "Convert svg to tiff in storage" do
1658
+ result_name = "putSvgToTiff.tiff"
1659
+ out_path = "HtmlTestDoc/" + result_name
1660
+ out_format = "tiff"
1661
+
1662
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1663
+
1664
+ expect(answer[:status]).to eql(200)
1665
+
1666
+ #Download converted file from storage
1667
+ res = download_file_helper(result_name)
1668
+ expect(res).to be_an_instance_of File
1669
+
1670
+ #Move to test folder
1671
+ save_to_test_dir(res, result_name)
1672
+ end
1673
+
1674
+ it "Convert svg to gif in storage" do
1675
+ result_name = "putSvgToGif.gif"
1676
+ out_path = "HtmlTestDoc/" + result_name
1677
+ out_format = "gif"
1678
+
1679
+ answer = @instance.put_convert_document_to_image(name, out_path, out_format, opts)
1680
+
1681
+ expect(answer[:status]).to eql(200)
1682
+
1683
+ #Download converted file from storage
1684
+ res = download_file_helper(result_name)
1685
+ expect(res).to be_an_instance_of File
1686
+
1687
+ #Move to test folder
1688
+ save_to_test_dir(res, result_name)
1689
+ end
1690
+ end
1691
+
1692
+ # unit tests for put_convert_document_to_pdf from html format
1693
+ # Converts the HTML document (located on storage) to PDF and uploads resulting file to storage.
1694
+ #
1695
+ # @param name Document name.
1696
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1697
+ # @param [Hash] opts the optional parameters
1698
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1699
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1700
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1701
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1702
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1703
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1704
+ # @option opts [String] :folder The source document folder.
1705
+ # @option opts [String] :storage The source and resulting document storage.
1706
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1707
+ describe 'put_convert_html_to_pdf test' do
1708
+ it "Convert html to pdf in storage" do
1709
+
1710
+ # Already in the storage
1711
+ name = "test1.html"
1712
+ result_name = "putHtmlToPdf.pdf"
1713
+ out_path = "HtmlTestDoc/" + result_name
1714
+ opts = {
1715
+ width: 800,
1716
+ height: 1000,
1717
+ left_margin: 30,
1718
+ right_margin: 30,
1719
+ top_margin: 50,
1720
+ bottom_margin: 50,
1721
+ folder: "HtmlTestDoc",
1722
+ storage: nil
1723
+ }
1724
+
1725
+ answer = @instance.put_convert_document_to_pdf(name, out_path, opts)
1726
+
1727
+ expect(answer[:status]).to eql(200)
1728
+
1729
+ #Download converted file from storage
1730
+ res = download_file_helper(result_name)
1731
+ expect(res).to be_an_instance_of File
1732
+
1733
+ #Move to test folder
1734
+ save_to_test_dir(res, result_name)
1735
+ end
1736
+ end
1737
+
1738
+ # unit tests for put_convert_document_to_pdf from epub format
1739
+ # Converts the EPUB document (located on storage) to PDF and uploads resulting file to storage.
1740
+ #
1741
+ # @param name Document name.
1742
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1743
+ # @param [Hash] opts the optional parameters
1744
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1745
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1746
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1747
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1748
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1749
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1750
+ # @option opts [String] :folder The source document folder.
1751
+ # @option opts [String] :storage The source and resulting document storage.
1752
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1753
+ describe 'put_convert_epub_to_pdf test' do
1754
+ it "Convert epub to pdf in storage" do
1755
+
1756
+ # Already in the storage
1757
+ name = "georgia.epub"
1758
+ result_name = "putEpubToPdf.pdf"
1759
+ out_path = "HtmlTestDoc/" + result_name
1760
+ opts = {
1761
+ width: 800,
1762
+ height: 1000,
1763
+ left_margin: 30,
1764
+ right_margin: 30,
1765
+ top_margin: 50,
1766
+ bottom_margin: 50,
1767
+ folder: "HtmlTestDoc",
1768
+ storage: nil
1769
+ }
1770
+
1771
+ answer = @instance.put_convert_document_to_pdf(name, out_path, opts)
1772
+
1773
+ expect(answer[:status]).to eql(200)
1774
+
1775
+ #Download converted file from storage
1776
+ res = download_file_helper(result_name)
1777
+ expect(res).to be_an_instance_of File
1778
+
1779
+ #Move to test folder
1780
+ save_to_test_dir(res, result_name)
1781
+ end
1782
+ end
1783
+
1784
+ # unit tests for put_convert_document_to_pdf from svg format
1785
+ # Converts the SVG document (located on storage) to PDF and uploads resulting file to storage.
1786
+ #
1787
+ # @param name Document name.
1788
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.pdf)
1789
+ # @param [Hash] opts the optional parameters
1790
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1791
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1792
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1793
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1794
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1795
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1796
+ # @option opts [String] :folder The source document folder.
1797
+ # @option opts [String] :storage The source and resulting document storage.
1798
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1799
+ describe 'put_convert_svg_to_pdf test' do
1800
+ it "Convert svg to pdf in storage" do
1801
+
1802
+ # Already in the storage
1803
+ name = "Map-World.svg"
1804
+ result_name = "putSvgToPdf.pdf"
1805
+ out_path = "HtmlTestDoc/" + result_name
1806
+ opts = {
1807
+ width: 800,
1808
+ height: 1000,
1809
+ left_margin: 30,
1810
+ right_margin: 30,
1811
+ top_margin: 50,
1812
+ bottom_margin: 50,
1813
+ folder: "HtmlTestDoc",
1814
+ storage: nil
1815
+ }
1816
+
1817
+ answer = @instance.put_convert_document_to_pdf(name, out_path, opts)
1818
+
1819
+ expect(answer[:status]).to eql(200)
1820
+
1821
+ #Download converted file from storage
1822
+ res = download_file_helper(result_name)
1823
+ expect(res).to be_an_instance_of File
1824
+
1825
+ #Move to test folder
1826
+ save_to_test_dir(res, result_name)
1827
+ end
1828
+ end
1829
+
1830
+ # unit tests for put_convert_document_to_xps from html format
1831
+ # Converts the HTML document (located on storage) to XPS and uploads resulting file to storage.
1832
+ #
1833
+ # @param name Document name.
1834
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1835
+ # @param [Hash] opts the optional parameters
1836
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1837
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1838
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1839
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1840
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1841
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1842
+ # @option opts [String] :folder The source document folder.
1843
+ # @option opts [String] :storage The source and resulting document storage.
1844
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1845
+ describe 'put_convert_html_to_xps test' do
1846
+ it "Convert html to xps in storage" do
1847
+
1848
+ # Already in the storage
1849
+ name = "test1.html"
1850
+ result_name = "putHtmlToXps.xps"
1851
+ out_path = "HtmlTestDoc/" + result_name
1852
+ opts = {
1853
+ width: 800,
1854
+ height: 1000,
1855
+ left_margin: 30,
1856
+ right_margin: 30,
1857
+ top_margin: 50,
1858
+ bottom_margin: 50,
1859
+ folder: "HtmlTestDoc",
1860
+ storage: nil
1861
+ }
1862
+
1863
+ answer = @instance.put_convert_document_to_xps(name, out_path, opts)
1864
+
1865
+ expect(answer[:status]).to eql(200)
1866
+
1867
+ #Download converted file from storage
1868
+ res = download_file_helper(result_name)
1869
+ expect(res).to be_an_instance_of File
1870
+
1871
+ #Move to test folder
1872
+ save_to_test_dir(res, result_name)
1873
+ end
1874
+ end
1875
+
1876
+ # unit tests for put_convert_document_to_xps from epub format
1877
+ # Converts the EPUB document (located on storage) to XPS and uploads resulting file to storage.
1878
+ #
1879
+ # @param name Document name.
1880
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1881
+ # @param [Hash] opts the optional parameters
1882
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1883
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1884
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1885
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1886
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1887
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1888
+ # @option opts [String] :folder The source document folder.
1889
+ # @option opts [String] :storage The source and resulting document storage.
1890
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1891
+ describe 'put_convert_epub_to_xps test' do
1892
+ it "Convert epub to xps in storage" do
1893
+
1894
+ # Already in the storage
1895
+ name = "georgia.epub"
1896
+ result_name = "putEpubToXps.xps"
1897
+ out_path = "HtmlTestDoc/" + result_name
1898
+ opts = {
1899
+ width: 800,
1900
+ height: 1000,
1901
+ left_margin: 30,
1902
+ right_margin: 30,
1903
+ top_margin: 50,
1904
+ bottom_margin: 50,
1905
+ folder: "HtmlTestDoc",
1906
+ storage: nil
1907
+ }
1908
+
1909
+ answer = @instance.put_convert_document_to_xps(name, out_path, opts)
1910
+
1911
+ expect(answer[:status]).to eql(200)
1912
+
1913
+ #Download converted file from storage
1914
+ res = download_file_helper(result_name)
1915
+ expect(res).to be_an_instance_of File
1916
+
1917
+ #Move to test folder
1918
+ save_to_test_dir(res, result_name)
1919
+ end
1920
+ end
1921
+
1922
+ # unit tests for put_convert_document_to_xps from svg format
1923
+ # Converts the SVG document (located on storage) to XPS and uploads resulting file to storage.
1924
+ #
1925
+ # @param name Document name.
1926
+ # @param out_path Full resulting filename (ex. /folder1/folder2/result.xps)
1927
+ # @param [Hash] opts the optional parameters
1928
+ # @option opts [Integer] :width Resulting document page width in points (1/96 inch).
1929
+ # @option opts [Integer] :height Resulting document page height in points (1/96 inch).
1930
+ # @option opts [Integer] :left_margin Left resulting document page margin in points (1/96 inch).
1931
+ # @option opts [Integer] :right_margin Right resulting document page margin in points (1/96 inch).
1932
+ # @option opts [Integer] :top_margin Top resulting document page margin in points (1/96 inch).
1933
+ # @option opts [Integer] :bottom_margin Bottom resulting document page margin in points (1/96 inch).
1934
+ # @option opts [String] :folder The source document folder.
1935
+ # @option opts [String] :storage The source and resulting document storage.
1936
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1937
+ describe 'put_convert_svg_to_xps test' do
1938
+ it "Convert svg to xps in storage" do
1939
+
1940
+ # Already in the storage
1941
+ name = "Map-World.svg"
1942
+ result_name = "putSvgToXps.xps"
1943
+ out_path = "HtmlTestDoc/" + result_name
1944
+ opts = {
1945
+ width: 800,
1946
+ height: 1000,
1947
+ left_margin: 30,
1948
+ right_margin: 30,
1949
+ top_margin: 50,
1950
+ bottom_margin: 50,
1951
+ folder: "HtmlTestDoc",
1952
+ storage: nil
1953
+ }
1954
+
1955
+ answer = @instance.put_convert_document_to_xps(name, out_path, opts)
1956
+
1957
+ expect(answer[:status]).to eql(200)
1958
+
1959
+ #Download converted file from storage
1960
+ res = download_file_helper(result_name)
1961
+ expect(res).to be_an_instance_of File
1962
+
1963
+ #Move to test folder
1964
+ save_to_test_dir(res, result_name)
1965
+ end
1966
+ end
1967
+
1968
+ # unit tests for get_convert_document_to_mhtml_by_url
1969
+ #
1970
+ # Converts the HTML page from Web by its URL to MHTML returns resulting file in response content.
1971
+ # @param source_url Source page URL.
1972
+ # @param [Hash] opts the optional parameters
1973
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1974
+ describe 'get_convert_document_to_mhtml_by_url test' do
1975
+ it "Convert url to mhtml" do
1976
+ source_url = "https://www.yahoo.com"
1977
+ opts = {}
1978
+
1979
+ answer = @instance.get_convert_document_to_mhtml_by_url(source_url, opts)
1980
+
1981
+ expect(answer).to be_an_instance_of Hash
1982
+ expect(answer[:file]).to be_an_instance_of File
1983
+ expect(answer[:status]).to eql(200)
1984
+
1985
+ # Save to test dir
1986
+ save_to_test_dir(answer[:file], "Convert_url.mht")
1987
+ end
1988
+ end
1989
+
1990
+ # unit tests for get_convert_document_to_markdown
1991
+ # Converts the HTML document (located on storage) to Markdown and returns resulting file in response content.
1992
+ # @param name Document name.
1993
+ # @param [Hash] opts the optional parameters
1994
+ # @option opts [String] :use_git Use Git Markdown flavor to save ("true" or "false"). (default to "false")
1995
+ # @option opts [String] :folder Source document folder.
1996
+ # @option opts [String] :storage Source document storage.
1997
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
1998
+ describe 'get_convert_document_to_markdown test' do
1999
+ it "Convert html to markdown" do
2000
+ name = "test_md.html"
2001
+ opts = {
2002
+ use_git: "true",
2003
+ folder: "HtmlTestDoc",
2004
+ storage: nil
2005
+ }
2006
+
2007
+ # Upload file to server
2008
+ res = upload_file_helper(name)
2009
+ expect(res.uploaded.length).to eql(1)
2010
+ expect(res.errors.length).to eql(0)
2011
+
2012
+ answer = @instance.get_convert_document_to_markdown(name, opts)
2013
+
2014
+ expect(answer).to be_an_instance_of Hash
2015
+ expect(answer[:file]).to be_an_instance_of File
2016
+ expect(answer[:status]).to eql(200)
2017
+
2018
+ # Save to test dir
2019
+ save_to_test_dir(answer[:file], "get_convert_markdown.md")
2020
+ end
2021
+ end
2022
+
2023
+ # unit tests for post_convert_document_in_request_to_markdown
2024
+ # Converts the HTML document (in request content) to Markdown and uploads resulting file to storage by specified path.
2025
+ # @param out_path Full resulting file path in the storage (ex. /folder1/folder2/result.md)
2026
+ # @param file A file to be converted.
2027
+ # @param [Hash] opts the optional parameters
2028
+ # @option opts [String] :use_git Use Git Markdown flavor to save ("true" or "false"). (default to "false")
2029
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2030
+ describe 'post_convert_document_in_request_to_markdown test' do
2031
+ it "Upload and convert html to markdown" do
2032
+ name = "postConvertInReqRuby.md"
2033
+ out_path = "HtmlTestDoc/" + name
2034
+ file = File.realpath(__dir__ + '/../../testdata/test_md.html')
2035
+ opts = { use_git: "false" }
2036
+
2037
+ answer = @instance.post_convert_document_in_request_to_markdown(out_path, file, opts)
2038
+
2039
+ expect(answer[:status]).to eql(200)
2040
+
2041
+ #Download converted file from storage
2042
+ res = download_file_helper(name)
2043
+ expect(res).to be_an_instance_of File
2044
+
2045
+ #Move to test folder
2046
+ save_to_test_dir(res, name)
2047
+ end
2048
+ end
2049
+
2050
+ # unit tests for put_convert_document_to_markdown
2051
+ # Converts the HTML document (located on storage) to Markdown and uploads resulting file to storage by specified path.
2052
+ # @param name Document name.
2053
+ # @param out_path Full resulting file path in the storage (ex. /folder1/folder2/result.md)
2054
+ # @param [Hash] opts the optional parameters
2055
+ # @option opts [String] :use_git Use Git Markdown flavor to save ("true" or "false"). (default to "false")
2056
+ # @option opts [String] :folder The source document folder.
2057
+ # @option opts [String] :storage The source and resulting document storage.
2058
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2059
+ describe 'put_convert_document_to_markdown test' do
2060
+ it "Convert html to markdown and save result in the storage" do
2061
+
2062
+ # Already in the storage
2063
+ name = "test_md.html"
2064
+ result_name = "putConvertRuby.md"
2065
+ out_path = "HtmlTestDoc/" + result_name
2066
+ opts = {
2067
+ use_git: "true",
2068
+ folder: "HtmlTestDoc",
2069
+ storage: nil
2070
+ }
2071
+
2072
+ answer = @instance.put_convert_document_to_markdown(name, out_path, opts)
2073
+
2074
+ expect(answer[:status]).to eql(200)
2075
+
2076
+ #Download converted file from storage
2077
+ res = download_file_helper(result_name)
2078
+ expect(res).to be_an_instance_of File
2079
+
2080
+ #Move to test folder
2081
+ save_to_test_dir(res, result_name)
2082
+ end
2083
+ end
2084
+
2085
+ #################################################
2086
+ # Import API
2087
+ #################################################
2088
+
2089
+ # unit tests for get_convert_markdown_to_html
2090
+ # Converts the Markdown document (located on storage) to HTML and returns resulting file in response content.
2091
+ # @param name Document name.
2092
+ # @param [Hash] opts the optional parameters
2093
+ # @option opts [String] :folder Source document folder.
2094
+ # @option opts [String] :storage Source document storage.
2095
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2096
+ describe 'get_convert_markdown_to_html test' do
2097
+ it "Convert markdown to html" do
2098
+ name = "testpage1.md"
2099
+ opts = {
2100
+ folder: "HtmlTestDoc",
2101
+ storage: nil
2102
+ }
2103
+
2104
+ # Upload file to server
2105
+ res = upload_file_helper(name)
2106
+ expect(res.uploaded.length).to eql(1)
2107
+ expect(res.errors.length).to eql(0)
2108
+
2109
+ answer = @instance.get_convert_markdown_to_html(name, opts)
2110
+
2111
+ expect(answer).to be_an_instance_of Hash
2112
+ expect(answer[:file]).to be_an_instance_of File
2113
+ expect(answer[:status]).to eql(200)
2114
+
2115
+ # Save to test dir
2116
+ save_to_test_dir(answer[:file], "get_convert_md_html.html")
2117
+ end
2118
+ end
2119
+
2120
+ # unit tests for post_convert_markdown_in_request_to_html
2121
+ # Converts the Markdown document (in request content) to HTML and uploads resulting file to storage by specified path.
2122
+ # @param out_path Full resulting file path in the storage (ex. /folder1/folder2/result.html)
2123
+ # @param file A file to be converted.
2124
+ # @param [Hash] opts the optional parameters
2125
+ # @option opts [String] :storage Source document storage.
2126
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2127
+ describe 'post_convert_markdown_in_request_to_html test' do
2128
+ it "Upload and convert markdown to html" do
2129
+ name = "postMarkdownToHtmlInReqRuby.html"
2130
+ out_path = "HtmlTestDoc/" + name
2131
+ file = File.realpath(__dir__ + '/../../testdata/testpage1.md')
2132
+ opts = { storage: nil }
2133
+
2134
+ answer = @instance.post_convert_markdown_in_request_to_html(out_path, file, opts)
2135
+
2136
+ expect(answer[:status]).to eql(200)
2137
+
2138
+ #Download converted file from storage
2139
+ res = download_file_helper(name)
2140
+ expect(res).to be_an_instance_of File
2141
+
2142
+ #Move to test folder
2143
+ save_to_test_dir(res, name)
2144
+ end
2145
+ end
2146
+
2147
+ # unit tests for put_convert_markdown_to_html
2148
+ # Converts the Markdown document (located on storage) to HTML and uploads resulting file to storage by specified path.
2149
+ # @param name Document name.
2150
+ # @param out_path Full resulting file path in the storage (ex. /folder1/folder2/result.html)
2151
+ # @param [Hash] opts the optional parameters
2152
+ # @option opts [String] :folder The source document folder.
2153
+ # @option opts [String] :storage The source and resulting document storage.
2154
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2155
+ describe 'put_convert_markdown_to_html test' do
2156
+ it "Convert markdown to html and save result in the storage" do
2157
+
2158
+ # Already in the storage
2159
+ name = "testpage1.md"
2160
+ result_name = "putConvertMarkdownToHtmlRuby.html"
2161
+ out_path = "HtmlTestDoc/" + result_name
2162
+ opts = {
2163
+ folder: "HtmlTestDoc",
2164
+ storage: nil
2165
+ }
2166
+
2167
+ answer = @instance.put_convert_markdown_to_html(name, out_path, opts)
2168
+
2169
+ expect(answer[:status]).to eql(200)
2170
+
2171
+ #Download converted file from storage
2172
+ res = download_file_helper(result_name)
2173
+ expect(res).to be_an_instance_of File
2174
+
2175
+ #Move to test folder
2176
+ save_to_test_dir(res, result_name)
2177
+ end
2178
+ end
2179
+
2180
+ #################################################
2181
+ # Document API
2182
+ #################################################
2183
+
2184
+ # unit tests for document_get_document_by_url
2185
+ # Return all HTML page with linked resources packaged as a ZIP archive by the source page URL.
2186
+ #
2187
+ # @param source_url Source page URL.
2188
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2189
+ describe 'get_document_by_url test' do
2190
+ it "Get document and all linked resources from url" do
2191
+
2192
+ source_url = "https://lenta.ru/"
2193
+ answer = @instance.get_document_by_url(source_url)
2194
+
2195
+ expect(answer).to be_an_instance_of Hash
2196
+ expect(answer[:file]).to be_an_instance_of File
2197
+ expect(answer[:status]).to eql(200)
2198
+
2199
+ # Save to test dir
2200
+ save_to_test_dir(answer[:file], "Get_site_from_url.zip")
2201
+ end
2202
+ end
2203
+
2204
+ # unit tests for get_document_fragment_by_x_path
2205
+ # Return list of HTML fragments matching the specified XPath query.
2206
+ #
2207
+ # @param name The document name.
2208
+ # @param x_path XPath query string.
2209
+ # @param out_format Output format. Possible values: &#39;plain&#39; and &#39;json&#39;.
2210
+ # @param [Hash] opts the optional parameters
2211
+ # @option opts [String] :storage The document storage.
2212
+ # @option opts [String] :folder The document folder.
2213
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2214
+ describe 'get_document_fragment_by_x_path test' do
2215
+ it "Get fragment document" do
2216
+ name = "test2.html.zip"
2217
+ x_path = ".//p"
2218
+ out_format = "plain"
2219
+ opts = {folder: "HtmlTestDoc", storage: nil}
2220
+
2221
+ # Upload file to server
2222
+ res = upload_file_helper(name)
2223
+ expect(res.uploaded.length).to eql(1)
2224
+ expect(res.errors.length).to eql(0)
2225
+
2226
+ answer = @instance.get_document_fragment_by_x_path(name, x_path, out_format, opts)
2227
+
2228
+ expect(answer).to be_an_instance_of Hash
2229
+ expect(answer[:file]).to be_an_instance_of File
2230
+ expect(answer[:status]).to eql(200)
2231
+
2232
+ # Save to test dir
2233
+ save_to_test_dir(answer[:file], "Get_fragment_doc.html")
2234
+ end
2235
+ end
2236
+
2237
+ # unit tests for document_get_document_fragment_by_x_path_by_url
2238
+ # Return list of HTML fragments matching the specified XPath query by the source page URL.
2239
+ #
2240
+ # @param source_url Source page URL.
2241
+ # @param x_path XPath query string.
2242
+ # @param out_format Output format. Possible values: &#39;plain&#39; and &#39;json&#39;.
2243
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2244
+ describe 'get_document_fragment_by_x_path_by_url test' do
2245
+ it "Get fragment document by url" do
2246
+ source_url = "https://stallman.org/articles/anonymous-payments-thru-phones.html"
2247
+ x_path = ".//p"
2248
+ out_format = "plain"
2249
+
2250
+ answer = @instance.get_document_fragment_by_x_path_by_url(source_url, x_path, out_format)
2251
+
2252
+ expect(answer).to be_an_instance_of Hash
2253
+ expect(answer[:file]).to be_an_instance_of File
2254
+ expect(answer[:status]).to eql(200)
2255
+
2256
+ # Save to test dir
2257
+ save_to_test_dir(answer[:file], "Get_fragment_xpath_by_url.html")
2258
+ end
2259
+ end
2260
+
2261
+ # Return list of HTML fragments matching the specified CSS selector.
2262
+ #
2263
+ # @param name The document name.
2264
+ # @param selector CSS selector string.
2265
+ # @param out_format Output format. Possible values: &#39;plain&#39; and &#39;json&#39;.
2266
+ # @param [Hash] opts the optional parameters
2267
+ # @option opts [String] :folder The document folder.
2268
+ # @option opts [String] :storage The document storage.
2269
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2270
+ describe 'get_document_fragments_by_css_selector test' do
2271
+ it "Get fragment document by css" do
2272
+ name = "test2.html.zip"
2273
+ selector = "div p"
2274
+ out_format = "plain"
2275
+ opts = {folder: "HtmlTestDoc", storage: nil}
2276
+
2277
+ # Upload file to server
2278
+ res = upload_file_helper(name)
2279
+ expect(res.uploaded.length).to eql(1)
2280
+ expect(res.errors.length).to eql(0)
2281
+
2282
+ answer = @instance.get_document_fragments_by_css_selector(name, selector, out_format, opts)
2283
+
2284
+ expect(answer).to be_an_instance_of Hash
2285
+ expect(answer[:file]).to be_an_instance_of File
2286
+ expect(answer[:status]).to eql(200)
2287
+
2288
+ # Save to test dir
2289
+ save_to_test_dir(answer[:file], "Get_fragment_doc_css.html")
2290
+ end
2291
+ end
2292
+
2293
+ # Return list of HTML fragments matching the specified CSS selector by the source page URL.
2294
+ #
2295
+ # @param source_url Source page URL.
2296
+ # @param selector CSS selector string.
2297
+ # @param out_format Output format. Possible values: &#39;plain&#39; and &#39;json&#39;.
2298
+ # @param [Hash] opts the optional parameters
2299
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2300
+ describe 'get_document_fragments_by_css_selector_by_url test' do
2301
+ it "Get fragment document matching the specified CSS selector by url" do
2302
+ source_url = "https://www.w3schools.com/cssref/css_selectors.asp"
2303
+ selector = 'a[href$=".asp"]'
2304
+ out_format = "plain"
2305
+
2306
+ answer = @instance.get_document_fragments_by_css_selector_by_url(source_url, selector, out_format)
2307
+
2308
+ expect(answer).to be_an_instance_of Hash
2309
+ expect(answer[:file]).to be_an_instance_of File
2310
+ expect(answer[:status]).to eql(200)
2311
+
2312
+ # Save to test dir
2313
+ save_to_test_dir(answer[:file], "Get_fragment_css_by_url.html")
2314
+ end
2315
+ end
2316
+
2317
+ # unit tests for get_document_images
2318
+ # Return all HTML document images packaged as a ZIP archive.
2319
+ #
2320
+ # @param name The document name.
2321
+ # @param [Hash] opts the optional parameters
2322
+ # @option opts [String] :folder The document folder.
2323
+ # @option opts [String] :storage The document storage.
2324
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2325
+ describe 'get_document_images test' do
2326
+ it "Get images from document" do
2327
+ name = "test3.html.zip"
2328
+ opts = {folder: "HtmlTestDoc", storage: nil}
2329
+
2330
+ # Upload file to server
2331
+ res = upload_file_helper(name)
2332
+ expect(res.uploaded.length).to eql(1)
2333
+ expect(res.errors.length).to eql(0)
2334
+
2335
+ answer = @instance.get_document_images(name, opts)
2336
+
2337
+ expect(answer).to be_an_instance_of Hash
2338
+ expect(answer[:file]).to be_an_instance_of File
2339
+ expect(answer[:status]).to eql(200)
2340
+
2341
+ # Save to test dir
2342
+ save_to_test_dir(answer[:file], "Get_images_doc.zip")
2343
+ end
2344
+ end
2345
+
2346
+ # unit tests for document_get_document_images_by_url
2347
+ # Return all HTML page images packaged as a ZIP archive by the source page URL.
2348
+ #
2349
+ # @param source_url Source page URL.
2350
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2351
+ describe 'get_document_images_by_url test' do
2352
+ it "Get images from url" do
2353
+
2354
+ source_url = "https://www.google.com/"
2355
+ answer = @instance.get_document_images_by_url(source_url)
2356
+
2357
+ expect(answer).to be_an_instance_of Hash
2358
+ expect(answer[:file]).to be_an_instance_of File
2359
+ expect(answer[:status]).to eql(200)
2360
+
2361
+ # Save to test dir
2362
+ save_to_test_dir(answer[:file], "Get_images_from_url.zip")
2363
+ end
2364
+ end
2365
+
2366
+ #################################################
2367
+ # OCR API
2368
+ #################################################
2369
+
2370
+ # unit tests for get_recognize_and_import_to_html
2371
+ # Recognize text from the image file in the storage and import it to HTML format.
2372
+ #
2373
+ # @param name The image file name.
2374
+ # @param [Hash] opts the optional parameters
2375
+ # @option opts [String] :ocr_engine_lang OCR engine language - language
2376
+ # @option opts [String] :folder The source image folder.
2377
+ # @option opts [String] :storage The source image storage.
2378
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2379
+ describe 'get_recognize_and_import_to_html test' do
2380
+ it "Recognize png" do
2381
+ file_name = "test_ocr.png"
2382
+ opts = {ocr_engine_lang: "en", folder: "HtmlTestDoc", storage: nil}
2383
+
2384
+ # Upload file to server
2385
+ res = upload_file_helper(file_name)
2386
+ expect(res.uploaded.length).to eql(1)
2387
+ expect(res.errors.length).to eql(0)
2388
+
2389
+ answer = @instance.get_recognize_and_import_to_html(file_name, opts)
2390
+
2391
+ expect(answer).to be_an_instance_of Hash
2392
+ expect(answer[:file]).to be_an_instance_of File
2393
+ expect(answer[:status]).to eql(200)
2394
+
2395
+ # Save to test dir
2396
+ save_to_test_dir(answer[:file], "Recognize_en_png.html")
2397
+ end
2398
+ end
2399
+
2400
+ # unit tests for get_recognize_and_translate_to_html
2401
+ # Recognize text from the image file in the storage, import it to HTML format and translate to specified language.
2402
+ #
2403
+ # @param name The image file name.
2404
+ # @param src_lang Source language - also supposed as the OCR engine language.
2405
+ # @param res_lang Result language.
2406
+ # @param [Hash] opts the optional parameters
2407
+ # @option opts [String] :folder The source image folder.
2408
+ # @option opts [String] :storage The source image storage.
2409
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2410
+ describe 'get_recognize_and_translate_to_html test' do
2411
+ it "Recognize and translate jpg" do
2412
+ file_name = "test_ocr.jpg"
2413
+ src_lang = "en"
2414
+ res_lang = "de"
2415
+ opts = {folder: "HtmlTestDoc", storage: nil}
2416
+
2417
+ # Upload file to server
2418
+ res = upload_file_helper(file_name)
2419
+ expect(res.uploaded.length).to eql(1)
2420
+ expect(res.errors.length).to eql(0)
2421
+
2422
+ answer = @instance.get_recognize_and_translate_to_html(file_name, src_lang, res_lang, opts)
2423
+
2424
+ expect(answer).to be_an_instance_of Hash
2425
+ expect(answer[:file]).to be_an_instance_of File
2426
+ expect(answer[:status]).to eql(200)
2427
+
2428
+ # Save to test dir
2429
+ save_to_test_dir(answer[:file], "Recognize_en_de_jpg.html")
2430
+ end
2431
+ end
2432
+
2433
+ #################################################
2434
+ # Translation API
2435
+ #################################################
2436
+
2437
+ # unit tests for get_translate_document
2438
+ # Translate the HTML document specified by the name from default or specified storage.
2439
+ #
2440
+ # @param name Document name.
2441
+ # @param src_lang Source language.
2442
+ # @param res_lang Result language.
2443
+ # @param [Hash] opts the optional parameters
2444
+ # @option opts [String] :storage The source document storage.
2445
+ # @option opts [String] :folder The source document folder.
2446
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2447
+ describe 'get_translate_document test' do
2448
+ it "Translate document" do
2449
+ file_name = "test_en.html"
2450
+ src_lang = "en"
2451
+ res_lang = "de"
2452
+ opts = {storage: nil, folder: "HtmlTestDoc"}
2453
+
2454
+ # Upload file to server
2455
+ res = upload_file_helper(file_name)
2456
+ expect(res.uploaded.length).to eql(1)
2457
+ expect(res.errors.length).to eql(0)
2458
+
2459
+ answer = @instance.get_translate_document(file_name, src_lang, res_lang, opts)
2460
+
2461
+ expect(answer).to be_an_instance_of Hash
2462
+ expect(answer[:file]).to be_an_instance_of File
2463
+ expect(answer[:status]).to eql(200)
2464
+
2465
+ # Save to test dir
2466
+ save_to_test_dir(answer[:file], "Translate_doc_en_de.html")
2467
+ end
2468
+ end
2469
+
2470
+ # unit tests for get_translate_document_by_url
2471
+ # Translate the HTML document from Web specified by its URL.
2472
+ #
2473
+ # @param source_url Source document URL.
2474
+ # @param src_lang Source language.
2475
+ # @param res_lang Result language.
2476
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2477
+ describe 'get_translate_document_by_url test' do
2478
+ it "Translate url" do
2479
+
2480
+ source_url = "https://www.le.ac.uk/oerresources/bdra/html/page_01.htm"
2481
+ src_lang = "en"
2482
+ res_lang = "fr"
2483
+
2484
+ answer = @instance.get_translate_document_by_url(source_url, src_lang,res_lang)
2485
+
2486
+ expect(answer).to be_an_instance_of Hash
2487
+ expect(answer[:file]).to be_an_instance_of File
2488
+ expect(answer[:status]).to eql(200)
2489
+
2490
+ # Save to test dir
2491
+ save_to_test_dir(answer[:file], "Translate_url_en_fr.zip")
2492
+ end
2493
+ end
2494
+
2495
+ #################################################
2496
+ # Summarization API
2497
+ #################################################
2498
+
2499
+ # unit tests for get_detect_html_keywords
2500
+ # Get the HTML document keywords using the keyword detection service.
2501
+ #
2502
+ # @param name Document name.
2503
+ # @param [Hash] opts the optional parameters
2504
+ # @option opts [String] :folder Document folder.
2505
+ # @option opts [String] :storage Document storage.
2506
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2507
+ describe 'get_detect_html_keywords test' do
2508
+ it "Keyword by html document" do
2509
+ name = "test_en.html"
2510
+ opts = {storage: nil, folder: "HtmlTestDoc"}
2511
+
2512
+ # Upload file to server
2513
+ res = upload_file_helper(name)
2514
+ expect(res.uploaded.length).to eql(1)
2515
+ expect(res.errors.length).to eql(0)
2516
+
2517
+ answer = @instance.get_detect_html_keywords(name, opts)
2518
+
2519
+ expect(answer).to be_an_instance_of Hash
2520
+ expect(answer[:file]).to be_an_instance_of File
2521
+ expect(answer[:status]).to eql(200)
2522
+
2523
+ # Save to test dir
2524
+ save_to_test_dir(answer[:file], "Keyword_by_doc.json")
2525
+ end
2526
+ end
2527
+
2528
+ # unit tests for get_detect_html_keywords_by_url
2529
+ # Get the keywords from HTML document from Web specified by its URL using the keyword detection service
2530
+ #
2531
+ # @param source_url Source document URL.
2532
+ # @return [Hash] {file: data, status: _status_code, headers: _headers}
2533
+ describe 'get_detect_html_keywords_by_url test' do
2534
+ it "Keyword by url" do
2535
+ source_url = "https://www.le.ac.uk/oerresources/bdra/html/page_01.htm"
2536
+
2537
+ answer = @instance.get_detect_html_keywords_by_url(source_url)
2538
+
2539
+ expect(answer).to be_an_instance_of Hash
2540
+ expect(answer[:file]).to be_an_instance_of File
2541
+ expect(answer[:status]).to eql(200)
2542
+
2543
+ # Save to test dir
2544
+ save_to_test_dir(answer[:file], "Keyword_by_url.json")
2545
+ end
2546
+ end
2547
+
2548
+ # unit tests for get_merge_html_template
2549
+ # Populate HTML document template with data located as a file in the storage.
2550
+ #
2551
+ # @param template_name Template document name. Template document is HTML or zipped HTML.
2552
+ # @param data_path Data source file path in the storage. Supported data format: XML
2553
+ # @param [Hash] opts the optional parameters
2554
+ # @option opts [String] :options Template merge options: reserved for further implementation.
2555
+ # @option opts [String] :folder The template document folder.
2556
+ # @option opts [String] :storage The template document and data source storage.
2557
+ # @return [File]
2558
+ describe 'get_merge_html_template test' do
2559
+ it "Get merge template" do
2560
+ template_name = "HtmlTemplate.html";
2561
+ data_name = "XmlSourceData.xml";
2562
+ folder = "HtmlTestDoc"
2563
+ opts = {storage: nil, folder: folder}
2564
+ data_path = folder + "/" + data_name
2565
+ # Upload template file to server
2566
+ res = upload_file_helper(template_name)
2567
+ expect(res.uploaded.length).to eql(1)
2568
+ expect(res.errors.length).to eql(0)
2569
+
2570
+ # Upload data file to server
2571
+ res = upload_file_helper(data_name)
2572
+ expect(res.uploaded.length).to eql(1)
2573
+ expect(res.errors.length).to eql(0)
2574
+
2575
+ opts = {options:"", folder:"HtmlTestDoc", storage: nil}
2576
+ answer = @instance.get_merge_html_template(template_name, data_path, opts)
2577
+ save_to_test_dir(answer[:file], "GetTemplateMergeRuby.html")
2578
+ end
2579
+ end
2580
+
2581
+ # unit tests for post_merge_html_template
2582
+ # Populate HTML document template with data from the request body. Result document will be saved to storage.
2583
+ #
2584
+ # @param template_name Template document name. Template document is HTML or zipped HTML.
2585
+ # @param out_path Result document path.
2586
+ # @param file A data file to populate template.
2587
+ # @param [Hash] opts the optional parameters
2588
+ # @option opts [String] :options Template merge options: reserved for further implementation.
2589
+ # @option opts [String] :folder The template document folder.
2590
+ # @option opts [String] :storage The template document and data source storage.
2591
+ # @return [File]
2592
+ describe 'post_merge_html_template test' do
2593
+ it "Post merge template" do
2594
+ result_name = "PostTemplateMergeRuby.html"
2595
+ template_name = "HtmlTemplate.html";
2596
+ data_name = "XmlSourceData.xml";
2597
+ folder = "HtmlTestDoc"
2598
+ opts = {options:"", folder:"HtmlTestDoc", storage: nil}
2599
+ out_path = folder + "/" + result_name
2600
+ file = File.realpath(__dir__ + '/../../testdata/' + data_name)
2601
+ answer = @instance.post_merge_html_template(template_name, out_path, file, opts)
2602
+ expect(answer[:status]).to eql(200)
2603
+
2604
+ #Download converted file from storage
2605
+ res = download_file_helper(result_name)
2606
+ expect(res).to be_an_instance_of File
2607
+
2608
+ #Move to test folder
2609
+ save_to_test_dir(res, result_name)
2610
+ end
2611
+ end
2612
+ end