aspose_html_cloud 19.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,430 @@
1
+ # -*- coding: utf-8 -*-
2
+ =begin
3
+ --------------------------------------------------------------------------------------------------------------------
4
+ <copyright company="Aspose" file="model_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_relative '../spec_helper'
30
+ require 'json'
31
+ require 'date'
32
+
33
+ describe 'Test models' do
34
+
35
+ describe 'DiscUsage' do
36
+ before(:all) do
37
+ # run before all test
38
+ @instance1 = AsposeHtml::DiscUsage.new({usedSize: 100, totalSize: 200})
39
+ @instance2 = AsposeHtml::DiscUsage.new({usedSize: 100, totalSize: 200})
40
+ @instance3 = AsposeHtml::DiscUsage.new({usedSize: 200, totalSize: 300})
41
+ end
42
+
43
+ it 'should create an instance of DiscUsage' do
44
+ expect(@instance1).to be_instance_of(AsposeHtml::DiscUsage)
45
+ expect(@instance2).to be_instance_of(AsposeHtml::DiscUsage)
46
+ expect(@instance3).to be_instance_of(AsposeHtml::DiscUsage)
47
+ end
48
+
49
+ it 'check class names' do
50
+ expect(@instance1.used_size).to be_instance_of(Integer)
51
+ expect(@instance2.used_size).to be_instance_of(Integer)
52
+ expect(@instance3.used_size).to be_instance_of(Integer)
53
+
54
+ expect(@instance1.total_size).to be_instance_of(Integer)
55
+ expect(@instance2.total_size).to be_instance_of(Integer)
56
+ expect(@instance3.total_size).to be_instance_of(Integer)
57
+ end
58
+
59
+ it 'check compare and keys' do
60
+ dictionary = @instance3.to_hash
61
+ expect(dictionary.has_key?(:usedSize)).to be true
62
+ expect(dictionary.has_key?(:totalSize)).to be true
63
+ expect(@instance1).to eql(@instance2)
64
+ expect(@instance1).not_to eql(@instance3)
65
+ end
66
+ end
67
+
68
+ describe 'Error' do
69
+ before(:all) do
70
+ @time_now = DateTime.now
71
+ @er_detail = AsposeHtml::ErrorDetails.new({request_id: '123456789', date: @time_now})
72
+ @error1 = AsposeHtml::Error.new({code: '404', message: 'Access denied',
73
+ description: 'description', inner_error: @er_detail})
74
+ @error2 = AsposeHtml::Error.new({code: '404', message: 'Access denied',
75
+ description: 'description', inner_error: @er_detail})
76
+ @error3 = AsposeHtml::Error.new({code: '500', message: 'Server error',
77
+ description: 'description', inner_error: @er_detail})
78
+ end
79
+
80
+ it 'should create an instance of Error' do
81
+ expect(@error1).to be_instance_of(AsposeHtml::Error)
82
+ expect(@error2).to be_instance_of(AsposeHtml::Error)
83
+ expect(@error3).to be_instance_of(AsposeHtml::Error)
84
+ end
85
+
86
+ it 'check class names' do
87
+ expect(@error1.code).to be_instance_of(String)
88
+ expect(@error2.code).to be_instance_of(String)
89
+ expect(@error3.code).to be_instance_of(String)
90
+
91
+ expect(@error1.message).to be_instance_of(String)
92
+ expect(@error2.message).to be_instance_of(String)
93
+ expect(@error3.message).to be_instance_of(String)
94
+
95
+ expect(@error1.description).to be_instance_of(String)
96
+ expect(@error2.description).to be_instance_of(String)
97
+ expect(@error3.description).to be_instance_of(String)
98
+
99
+ expect(@error1.inner_error).to be_instance_of(AsposeHtml::ErrorDetails)
100
+ expect(@error2.inner_error).to be_instance_of(AsposeHtml::ErrorDetails)
101
+ expect(@error3.inner_error).to be_instance_of(AsposeHtml::ErrorDetails)
102
+ end
103
+
104
+ it 'check compare and keys' do
105
+ dictionary = @error3.to_hash
106
+ expect(dictionary.has_key?(:code)).to be true
107
+ expect(dictionary.has_key?(:message)).to be true
108
+ expect(dictionary.has_key?(:description)).to be true
109
+ expect(dictionary.has_key?(:innerError)).to be true
110
+
111
+ expect(@error1).to eql(@error2)
112
+ expect(@error1).not_to eql(@error3)
113
+ end
114
+ end
115
+
116
+ describe 'ErrorDetails' do
117
+ before(:all) do
118
+ @time_now = DateTime.now
119
+ @er_detaill = AsposeHtml::ErrorDetails.new({request_id: '123456789', date: @time_now})
120
+ @er_detail2 = AsposeHtml::ErrorDetails.new({request_id: '123456789', date: @time_now})
121
+ @er_detail3 = AsposeHtml::ErrorDetails.new({request_id: '987654321', date: @time_now})
122
+ end
123
+
124
+ it 'should create an instance of ErrorDetails' do
125
+ expect(@er_detaill).to be_instance_of(AsposeHtml::ErrorDetails)
126
+ expect(@er_detail2).to be_instance_of(AsposeHtml::ErrorDetails)
127
+ expect(@er_detail3).to be_instance_of(AsposeHtml::ErrorDetails)
128
+ end
129
+
130
+ it 'check class names' do
131
+ expect(@er_detaill.request_id).to be_instance_of(String)
132
+ expect(@er_detail2.request_id).to be_instance_of(String)
133
+ expect(@er_detail3.request_id).to be_instance_of(String)
134
+
135
+ expect(@er_detaill.date).to be_instance_of(DateTime)
136
+ expect(@er_detail2.date).to be_instance_of(DateTime)
137
+ expect(@er_detail3.date).to be_instance_of(DateTime)
138
+ end
139
+
140
+ it 'check compare and keys' do
141
+ dictionary = @er_detaill.to_hash
142
+ expect(dictionary.has_key?(:requestId)).to be true
143
+ expect(dictionary.has_key?(:date)).to be true
144
+
145
+ expect(@er_detaill).to eql(@er_detail2)
146
+ expect(@er_detaill).not_to eql(@er_detail3)
147
+ end
148
+ end
149
+
150
+ describe 'FileVersion' do
151
+ before(:all) do
152
+ # run before all test
153
+ time_now = DateTime.now
154
+ @instance1 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: false, name: 'test',
155
+ isFolder: false, modifiedDate: time_now, size: 100, path: '/'})
156
+ @instance2 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: false, name: 'test',
157
+ isFolder: false, modifiedDate: time_now, size: 100, path: '/'})
158
+ @instance3 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: true, name: 'test',
159
+ isFolder: true, modifiedDate: time_now, size: 100, path: '/'})
160
+ end
161
+
162
+ it 'should create an instance of FileVersion' do
163
+ expect(@instance1).to be_instance_of(AsposeHtml::FileVersion)
164
+ expect(@instance2).to be_instance_of(AsposeHtml::FileVersion)
165
+ expect(@instance3).to be_instance_of(AsposeHtml::FileVersion)
166
+ end
167
+
168
+ it 'check class names' do
169
+ expect(@instance1.version_id).to be_instance_of(String)
170
+ expect(@instance2.version_id).to be_instance_of(String)
171
+ expect(@instance3.version_id).to be_instance_of(String)
172
+
173
+ expect(@instance1.is_latest).to be false
174
+ expect(@instance2.is_latest).to be false
175
+ expect(@instance3.is_latest).to be true
176
+
177
+ expect(@instance1.name).to be_instance_of(String)
178
+ expect(@instance2.name).to be_instance_of(String)
179
+ expect(@instance3.name).to be_instance_of(String)
180
+
181
+ expect(@instance1.is_folder).to be false
182
+ expect(@instance2.is_folder).to be false
183
+ expect(@instance3.is_folder).to be true
184
+
185
+ expect(@instance1.modified_date).to be_instance_of(DateTime)
186
+ expect(@instance2.modified_date).to be_instance_of(DateTime)
187
+ expect(@instance3.modified_date).to be_instance_of(DateTime)
188
+
189
+ expect(@instance1.size).to be_instance_of(Integer)
190
+ expect(@instance2.size).to be_instance_of(Integer)
191
+ expect(@instance3.size).to be_instance_of(Integer)
192
+
193
+ expect(@instance1.path).to be_instance_of(String)
194
+ expect(@instance2.path).to be_instance_of(String)
195
+ expect(@instance3.path).to be_instance_of(String)
196
+ end
197
+
198
+ it 'check compare and keys' do
199
+ dictionary = @instance3.to_hash
200
+ expect(dictionary.has_key?(:versionId)).to be true
201
+ expect(dictionary.has_key?(:isLatest)).to be true
202
+ expect(dictionary.has_key?(:name)).to be true
203
+ expect(dictionary.has_key?(:isFolder)).to be true
204
+ expect(dictionary.has_key?(:modifiedDate)).to be true
205
+ expect(dictionary.has_key?(:size)).to be true
206
+ expect(dictionary.has_key?(:path)).to be true
207
+
208
+ expect(@instance1).to eql(@instance2)
209
+ expect(@instance1).not_to eql(@instance3)
210
+ end
211
+ end
212
+
213
+ describe 'FileVersions' do
214
+ before(:all) do
215
+ time_now = DateTime.now
216
+ @v1 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: false, name: 'test',
217
+ isFolder: false, modifiedDate: time_now, size: 100, path: '/'})
218
+ @v2 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: false, name: 'test',
219
+ isFolder: false, modifiedDate: time_now, size: 100, path: '/'})
220
+ @v3 = AsposeHtml::FileVersion.new({versionId: "1.0.1", isLatest: true, name: 'test',
221
+ isFolder: true, modifiedDate: time_now, size: 100, path: '/'})
222
+
223
+ @instance1 = AsposeHtml::FileVersions.new({value:[@v1, @v2, @v3] })
224
+ @instance2 = AsposeHtml::FileVersions.new({value:[@v1, @v2, @v3] })
225
+ @instance3 = AsposeHtml::FileVersions.new({value:[@v2, @v3] })
226
+ end
227
+
228
+ it 'should create an instance of FileVersions' do
229
+ expect(@instance1).to be_instance_of(AsposeHtml::FileVersions)
230
+ expect(@instance2).to be_instance_of(AsposeHtml::FileVersions)
231
+ expect(@instance3).to be_instance_of(AsposeHtml::FileVersions)
232
+ end
233
+
234
+ it 'check class names' do
235
+ expect(@instance1.value).to be_instance_of(Array)
236
+ expect(@instance2.value).to be_instance_of(Array)
237
+ expect(@instance3.value).to be_instance_of(Array)
238
+ end
239
+
240
+ it 'check compare and keys' do
241
+ dictionary = @instance3.to_hash
242
+ expect(dictionary.has_key?(:value)).to be true
243
+ expect(@instance1).to eql(@instance2)
244
+ expect(@instance1).not_to eql(@instance3)
245
+ end
246
+ end
247
+
248
+ describe 'FilesList' do
249
+ before(:all) do
250
+ # run before all test
251
+ time_now = DateTime.now
252
+ @f1 = AsposeHtml::StorageFile.new({name: 'test', isFolder: false, modifiedDate: time_now,
253
+ size: 100, path: '~/user/test_path'})
254
+ @f2 = AsposeHtml::StorageFile.new({name: 'test', isFolder: false, modifiedDate: time_now,
255
+ size: 100, path: '~/user/test_path'})
256
+ @f3 = AsposeHtml::StorageFile.new({name: 'test', isFolder: true, modifiedDate: time_now,
257
+ size: 100, path: '~/user/test_path'})
258
+
259
+ @instance1 = AsposeHtml::FilesList.new( { value:[@f1, @f2, @f3] } )
260
+ @instance2 = AsposeHtml::FilesList.new( { value:[@f1, @f2, @f3] } )
261
+ @instance3 = AsposeHtml::FilesList.new( { value:[@f2, @f3] } )
262
+ end
263
+
264
+ it 'should create an instance of FilesList' do
265
+ expect(@instance1).to be_instance_of(AsposeHtml::FilesList)
266
+ expect(@instance2).to be_instance_of(AsposeHtml::FilesList)
267
+ expect(@instance3).to be_instance_of(AsposeHtml::FilesList)
268
+ end
269
+
270
+ it 'check class names' do
271
+ expect(@instance1.value).to be_instance_of(Array)
272
+ expect(@instance2.value).to be_instance_of(Array)
273
+ expect(@instance3.value).to be_instance_of(Array)
274
+ end
275
+
276
+ it 'check compare and keys' do
277
+ dictionary = @instance3.to_hash
278
+ expect(dictionary.has_key?(:value)).to be true
279
+
280
+ expect(@instance1).to eql(@instance2)
281
+ expect(@instance1).not_to eql(@instance3)
282
+ end
283
+ end
284
+
285
+ describe 'FileUploadResult' do
286
+ before(:all) do
287
+ @er_detail = AsposeHtml::ErrorDetails.new({request_id: '123456789', date: @time_now})
288
+ @error1 = AsposeHtml::Error.new({code: '404', message: 'Access denied',
289
+ description: 'description', inner_error: @er_detail})
290
+
291
+ @instance1 = AsposeHtml::FilesUploadResult.new({uploaded:['file1', 'file2'], errors:[]})
292
+ @instance2 = AsposeHtml::FilesUploadResult.new({uploaded:['file1', 'file2'], errors:[]})
293
+ @instance3 = AsposeHtml::FilesUploadResult.new({uploaded:[], errors:[@error1]})
294
+ end
295
+
296
+ it 'should create an instance of FileUploadResult' do
297
+ expect(@instance1).to be_instance_of(AsposeHtml::FilesUploadResult)
298
+ expect(@instance2).to be_instance_of(AsposeHtml::FilesUploadResult)
299
+ expect(@instance3).to be_instance_of(AsposeHtml::FilesUploadResult)
300
+ end
301
+
302
+ it 'check class names' do
303
+ expect(@instance1.uploaded).to be_instance_of(Array)
304
+ expect(@instance1.errors).to be_instance_of(Array)
305
+ end
306
+
307
+ it 'check compare and keys' do
308
+ dictionary = @instance3.to_hash
309
+ expect(dictionary.has_key?(:uploaded)).to be true
310
+ expect(dictionary.has_key?(:errors)).to be true
311
+
312
+ expect(@instance1).to eql(@instance2)
313
+ expect(@instance1).not_to eql(@instance3)
314
+ end
315
+ end
316
+
317
+ describe 'StorageExist' do
318
+ before(:all) do
319
+ @instance1 = AsposeHtml::StorageExist.new({exists: false})
320
+ @instance2 = AsposeHtml::StorageExist.new({exists: false})
321
+ @instance3 = AsposeHtml::StorageExist.new({exists: true})
322
+ end
323
+
324
+ it 'should create an instance of StorageExist' do
325
+ expect(@instance1).to be_instance_of(AsposeHtml::StorageExist)
326
+ expect(@instance2).to be_instance_of(AsposeHtml::StorageExist)
327
+ expect(@instance3).to be_instance_of(AsposeHtml::StorageExist)
328
+ end
329
+
330
+ it 'check class names' do
331
+ expect(@instance1.exists).to be false
332
+ expect(@instance2.exists).to be false
333
+ expect(@instance3.exists).to be true
334
+ end
335
+
336
+ it 'check compare and keys' do
337
+ dictionary = @instance3.to_hash
338
+ expect(dictionary.has_key?(:exists)).to be true
339
+
340
+ expect(@instance1).to eql(@instance2)
341
+ expect(@instance1).not_to eql(@instance3)
342
+ end
343
+ end
344
+
345
+ describe 'ObjectExist' do
346
+ before(:all) do
347
+ # run before all test
348
+ @instance1 = AsposeHtml::ObjectExist.new({exists: true, is_folder: false})
349
+ @instance2 = AsposeHtml::ObjectExist.new({exists: true, is_folder: false})
350
+ @instance3 = AsposeHtml::ObjectExist.new({exists: false, is_folder: false})
351
+ end
352
+
353
+ it 'should create an instance of ObjectExist' do
354
+ expect(@instance1).to be_instance_of(AsposeHtml::ObjectExist)
355
+ expect(@instance2).to be_instance_of(AsposeHtml::ObjectExist)
356
+ expect(@instance3).to be_instance_of(AsposeHtml::ObjectExist)
357
+ end
358
+
359
+ it 'check class names' do
360
+ expect(@instance1.exists).to be true
361
+ expect(@instance2.exists).to be true
362
+ expect(@instance3.exists).to be false
363
+
364
+ expect(@instance1.is_folder).to be false
365
+ expect(@instance2.is_folder).to be false
366
+ expect(@instance3.is_folder).to be false
367
+ end
368
+
369
+ it 'check compare and keys' do
370
+ dictionary = @instance1.to_hash
371
+ expect(dictionary.has_key?(:exists)).to be true
372
+ expect(dictionary.has_key?(:is_folder)).to be false
373
+ expect(@instance1).to eql(@instance2)
374
+ expect(@instance1).not_to eql(@instance3)
375
+ end
376
+ end
377
+
378
+ describe 'StorageFile' do
379
+ before(:all) do
380
+ time_now = DateTime.now
381
+ @instance1 = AsposeHtml::StorageFile.new({name: 'test', isFolder: false, modifiedDate: time_now,
382
+ size: 100, path: '~/user/test_path'})
383
+ @instance2 = AsposeHtml::StorageFile.new({name: 'test', isFolder: false, modifiedDate: time_now,
384
+ size: 100, path: '~/user/test_path'})
385
+ @instance3 = AsposeHtml::StorageFile.new({name: 'test', isFolder: true, modifiedDate: time_now,
386
+ size: 100, path: '~/user/test_path'})
387
+ end
388
+
389
+ it 'should create an instance of FileDetail' do
390
+ expect(@instance1).to be_instance_of(AsposeHtml::StorageFile)
391
+ expect(@instance2).to be_instance_of(AsposeHtml::StorageFile)
392
+ expect(@instance3).to be_instance_of(AsposeHtml::StorageFile)
393
+ end
394
+
395
+ it 'check class names' do
396
+ expect(@instance1.name).to be_instance_of(String)
397
+ expect(@instance2.name).to be_instance_of(String)
398
+ expect(@instance3.name).to be_instance_of(String)
399
+
400
+ expect(@instance1.is_folder).to be false
401
+ expect(@instance2.is_folder).to be false
402
+ expect(@instance3.is_folder).to be true
403
+
404
+ expect(@instance1.modified_date).to be_instance_of(DateTime)
405
+ expect(@instance2.modified_date).to be_instance_of(DateTime)
406
+ expect(@instance3.modified_date).to be_instance_of(DateTime)
407
+
408
+ expect(@instance1.size).to be_instance_of(Integer)
409
+ expect(@instance2.size).to be_instance_of(Integer)
410
+ expect(@instance3.size).to be_instance_of(Integer)
411
+
412
+ expect(@instance1.path).to be_instance_of(String)
413
+ expect(@instance2.path).to be_instance_of(String)
414
+ expect(@instance3.path).to be_instance_of(String)
415
+ end
416
+
417
+ it 'check compare and keys' do
418
+ dictionary = @instance3.to_hash
419
+ expect(dictionary.has_key?(:name)).to be true
420
+ expect(dictionary.has_key?(:isFolder)).to be true
421
+ expect(dictionary.has_key?(:modifiedDate)).to be true
422
+ expect(dictionary.has_key?(:size)).to be true
423
+ expect(dictionary.has_key?(:path)).to be true
424
+
425
+ expect(@instance1).to eql(@instance2)
426
+ expect(@instance1).not_to eql(@instance3)
427
+ end
428
+ end
429
+
430
+ end
@@ -0,0 +1,542 @@
1
+
2
+ # -*- coding: utf-8 -*-
3
+ =begin
4
+ --------------------------------------------------------------------------------------------------------------------
5
+ <copyright company="Aspose" file="storage_api_spec.rb">
6
+ </copyright>
7
+ Copyright (c) 2019 Aspose.HTML for Cloud
8
+ <summary>
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ </summary>
27
+ --------------------------------------------------------------------------------------------------------------------
28
+ =end
29
+
30
+ require 'spec_helper'
31
+ require 'json'
32
+
33
+ describe 'Test Storage API' do
34
+ before(:all) do
35
+ # run before all tests
36
+ @api = AsposeHtml::StorageApi.new CONFIG
37
+ end
38
+
39
+ describe 'test an instance of StorageApi' do
40
+ it 'should create an instance of StorageApi' do
41
+ expect(@api).to be_instance_of(AsposeHtml::StorageApi)
42
+ end
43
+ end
44
+
45
+ #################################################
46
+ # Storage API
47
+ #################################################
48
+
49
+ # Get disc usage
50
+ # @param [Hash] opts the optional parameters
51
+ # @option opts [String] :storage_name Storage name
52
+ # @return [DiscUsage]
53
+ describe 'get_disc_usage test' do
54
+ it "must be DiscUsage:{usedSize: num, totalSize: num}" do
55
+ opts = {storage_name: nil}
56
+ res = @api.get_disc_usage(opts)
57
+
58
+ expect(res).to be_an_instance_of AsposeHtml::DiscUsage
59
+ expect(res.used_size).to be_an_instance_of Integer
60
+ expect(res.total_size).to be_an_instance_of Integer
61
+ puts(res)
62
+ end
63
+ end
64
+
65
+ # Check if file or folder exists
66
+ # @param path File or folder path e.g. &#39;/file.ext&#39; or &#39;/folder&#39;
67
+ # @param [Hash] opts the optional parameters
68
+ # @option opts [String] :storage_name Storage name
69
+ # @option opts [String] :version_id File version ID
70
+ # @return [ObjectExist]
71
+ describe 'object_exists test' do
72
+ it "must be ObjectExist:{isExist: true, isFolder: false}" do
73
+
74
+ name = "test3.html.zip"
75
+
76
+ # Upload file to server
77
+ res = upload_file_helper(name)
78
+ expect(res.uploaded.length).to eql(1)
79
+ expect(res.errors.length).to eql(0)
80
+
81
+ path = "HtmlTestDoc/" + name
82
+ opts = {storage_name: nil, version_id: nil}
83
+
84
+ res = @api.object_exists(path, opts)
85
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
86
+ expect(res.exists).to be true
87
+ expect(res.is_folder).to be false
88
+ end
89
+
90
+ it "must be ObjectExist:{isExist: false, isFolder: false}" do
91
+
92
+ path = "/non_exist_file.ext"
93
+ opts = {storageName: nil, versionId: nil}
94
+
95
+ res = @api.object_exists(path, opts)
96
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
97
+ expect(res.exists).to be false
98
+ expect(res.is_folder).to be false
99
+ end
100
+ end
101
+
102
+ # Check if storage exists
103
+ # @param storage_name Storage name
104
+ # @param [Hash] opts the optional parameters
105
+ # @return [StorageExist]
106
+ describe 'storage_exists test' do
107
+ it "must be {'exists':false}" do
108
+
109
+ res = @api.storage_exists('non_exist_storage')
110
+ expect(res).to be_an_instance_of AsposeHtml::StorageExist
111
+ expect(res.exists).to be false
112
+ end
113
+ end
114
+
115
+ # Get file versions
116
+ # @param path File path e.g. &#39;/file.ext&#39;
117
+ # @param [Hash] opts the optional parameters
118
+ # @option opts [String] :storage_name Storage name
119
+ # @return [Array<(FileVersions, Fixnum, Hash)>] FileVersions data, response status code and response headers
120
+ describe 'get_file_versions test' do
121
+ it "must be {'value':[...]}" do
122
+
123
+ name = "test1.html"
124
+
125
+ # Upload file to server
126
+ res = upload_file_helper(name)
127
+ expect(res.uploaded.length).to eql(1)
128
+ expect(res.errors.length).to eql(0)
129
+
130
+ # Upload file to server
131
+ res = upload_file_helper(name)
132
+ expect(res.uploaded.length).to eql(1)
133
+ expect(res.errors.length).to eql(0)
134
+
135
+ # Upload file to server
136
+ res = upload_file_helper(name)
137
+ expect(res.uploaded.length).to eql(1)
138
+ expect(res.errors.length).to eql(0)
139
+
140
+ path = "HtmlTestDoc/" + name
141
+ opts = {storage_name: nil}
142
+
143
+ res = @api.get_file_versions(path, opts)
144
+
145
+ expect(res).to be_an_instance_of AsposeHtml::FileVersions
146
+ expect(res.value).to be_an_instance_of Array
147
+ expect(res.value[0]).to be_an_instance_of AsposeHtml::FileVersion
148
+ puts(res)
149
+ end
150
+ end
151
+
152
+ #################################################
153
+ # File API
154
+ #################################################
155
+
156
+ # unit tests for delete_file
157
+ # Remove a specific file
158
+ #
159
+ # Delete file
160
+ # @param path File path e.g. &#39;/folder/file.ext&#39;
161
+ # @param [Hash] opts the optional parameters
162
+ # @option opts [String] :storage_name Storage name
163
+ # @option opts [String] :version_id File version ID to delete
164
+ # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
165
+ describe 'delete_file test' do
166
+ it "return void, check if file not exist" do
167
+ name = "test_for_delete.html"
168
+
169
+ # Upload files to server
170
+ res = upload_file_helper(name)
171
+ expect(res.uploaded.length).to eql(1)
172
+ expect(res.errors.length).to eql(0)
173
+
174
+ path = "HtmlTestDoc/" + name
175
+ opts = {storage_name: nil, version_id: nil}
176
+
177
+ @api.delete_file(path, opts)
178
+
179
+ # Check result
180
+ res = @api.object_exists(path, opts)
181
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
182
+ expect(res.exists).to be false
183
+ expect(res.is_folder).to be false
184
+ end
185
+ end
186
+
187
+ # Download file
188
+ # @param path File path e.g. &#39;/folder/file.ext&#39;
189
+ # @param [Hash] opts the optional parameters
190
+ # @option opts [String] :storage_name Storage name
191
+ # @option opts [String] :version_id File version ID to download
192
+ # @return [File]
193
+ describe 'download_file test' do
194
+ it "must be file: path_to_tmp_file" do
195
+ name = "test_download.jpg"
196
+
197
+ # Upload files to server
198
+ res = upload_file_helper(name)
199
+ expect(res.uploaded.length).to eql(1)
200
+ expect(res.errors.length).to eql(0)
201
+
202
+ path = "HtmlTestDoc/" + name
203
+ opts = {storage_name: nil, version_id: nil}
204
+
205
+ size_src = get_file_size(name)
206
+
207
+ res = @api.download_file(path, opts)
208
+ expect(res).to be_an_instance_of File
209
+
210
+ expect(File.size(res.to_path)).to eql size_src
211
+
212
+ #Move to test folder
213
+ save_to_test_dir(res, name)
214
+
215
+ # clear
216
+ @api.delete_file(path, opts)
217
+
218
+ # Check result
219
+ res = @api.object_exists(path, opts)
220
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
221
+ expect(res.exists).to be false
222
+ expect(res.is_folder).to be false
223
+ end
224
+ end
225
+
226
+ # Copy file
227
+ # @param src_path Source file path e.g. &#39;/folder/file.ext&#39;
228
+ # @param dest_path Destination file path
229
+ # @param [Hash] opts the optional parameters
230
+ # @option opts [String] :src_storage_name Source storage name
231
+ # @option opts [String] :dest_storage_name Destination storage name
232
+ # @option opts [String] :version_id File version ID to copy
233
+ # @return nil
234
+ describe 'copy_file test' do
235
+ it "must be throw if error" do
236
+ name = "test_for_copy.html"
237
+
238
+ # Upload files to server
239
+ res = upload_file_helper(name)
240
+ expect(res.uploaded.length).to eql(1)
241
+ expect(res.errors.length).to eql(0)
242
+
243
+ src_path = "HtmlTestDoc/" + name
244
+ dest_path = "HtmlTestDoc/test_copied.html"
245
+
246
+ opts = {src_storage: nil, dest_storage: nil, version_id: nil}
247
+
248
+ @api.copy_file(src_path, dest_path, opts)
249
+
250
+ # Check result destination
251
+ res = @api.object_exists(dest_path)
252
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
253
+ expect(res.exists).to be true
254
+ expect(res.is_folder).to be false
255
+
256
+ # Check result source
257
+ res = @api.object_exists(src_path)
258
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
259
+ expect(res.exists).to be true
260
+ expect(res.is_folder).to be false
261
+
262
+ # Clear
263
+ @api.delete_file(src_path)
264
+ @api.delete_file(dest_path)
265
+ end
266
+ end
267
+
268
+ # unit tests for move_file
269
+ # Move a specific file
270
+ #
271
+ # @param src_path Source file path e.g. &#39;/src.ext&#39;
272
+ # @param dest_path Destination file path e.g. &#39;/dest.ext&#39;
273
+ # @param [Hash] opts the optional parameters
274
+ # @option opts [String] :src_storage_name Source storage name
275
+ # @option opts [String] :dest_storage_name Destination storage name
276
+ # @option opts [String] :version_id File version ID to move
277
+ # @return [nil]
278
+ describe 'move_file test' do
279
+ it "must be throw if error" do
280
+ name = "test_for_move.html"
281
+
282
+ # Upload files to server
283
+ res = upload_file_helper(name)
284
+ expect(res.uploaded.length).to eql(1)
285
+ expect(res.errors.length).to eql(0)
286
+
287
+ src_path = "HtmlTestDoc/" + name
288
+ dest_path = "HtmlTestDoc/test_moved.html"
289
+
290
+ opts = {src_storage: nil, dest_storage: nil, version_id: nil}
291
+
292
+ @api.move_file(src_path, dest_path, opts)
293
+
294
+ # Check result destination
295
+ res = @api.object_exists(dest_path)
296
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
297
+ expect(res.exists).to be true
298
+ expect(res.is_folder).to be false
299
+
300
+ # Check result source
301
+ res = @api.object_exists(src_path)
302
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
303
+ expect(res.exists).to be false
304
+ expect(res.is_folder).to be false
305
+
306
+ # Clear
307
+ @api.delete_file(dest_path)
308
+ end
309
+ end
310
+
311
+ # Upload file
312
+ # @param path Path where to upload including filename and extension e.g. /file.ext or /Folder 1/file.ext If the content is multipart and path does not contains the file name it tries to get them from filename parameter from Content-Disposition header.
313
+ # @param file File to upload
314
+ # @param [Hash] opts the optional parameters
315
+ # @option opts [String] :storage_name Storage name
316
+ # @return [FilesUploadResult]
317
+ describe 'upload_file test' do
318
+ it "must be FilesUploadResult" do
319
+ name = "test_upload_file.html"
320
+
321
+ path = "HtmlTestDoc/" + name
322
+ file = File.realpath(__dir__ + '/../../testdata/' + name)
323
+
324
+ opts = {storage_name: nil, version_id: nil}
325
+
326
+ res = @api.upload_file(path, file, opts)
327
+ expect(res.uploaded.length).to eql(1)
328
+ expect(res.errors.length).to eql(0)
329
+
330
+ # clear
331
+ @api.delete_file(path)
332
+ end
333
+ end
334
+
335
+ #################################################
336
+ # Folder API
337
+ #################################################
338
+
339
+ # Create the folder
340
+ # @param path Folder path to create e.g. &#39;folder_1/folder_2/&#39;
341
+ # @param [Hash] opts the optional parameters
342
+ # @option opts [String] :storage_name Storage name
343
+ # @return [nil]
344
+ describe 'create_folder test' do
345
+ it "must be throw if error" do
346
+
347
+ path = "HtmlTestDoc/testFolder1/testFolder2/testFolder3"
348
+
349
+ opts_exist = {storage_name: nil, version_id: nil}
350
+
351
+ # Check before
352
+ res = @api.object_exists(path, opts_exist)
353
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
354
+ expect(res.exists).to be false
355
+ expect(res.is_folder).to be false
356
+
357
+ opts_folder = {storage_name: nil}
358
+
359
+ @api.create_folder(path, opts_folder)
360
+
361
+ # Check after
362
+ res = @api.object_exists(path, opts_exist)
363
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
364
+ expect(res.exists).to be true
365
+ expect(res.is_folder).to be true
366
+
367
+ # clear
368
+ path = "HtmlTestDoc/testFolder1"
369
+ opts_delete = {storage_name: nil, recursive: true}
370
+
371
+ @api.delete_folder(path, opts_delete)
372
+
373
+ # Check after clear
374
+ res = @api.object_exists(path, opts_exist)
375
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
376
+ expect(res.exists).to be false
377
+ expect(res.is_folder).to be false
378
+ end
379
+ end
380
+
381
+ # Copy folder
382
+ # @param src_path Source folder path e.g. &#39;/src&#39;
383
+ # @param dest_path Destination folder path e.g. &#39;/dst&#39;
384
+ # @param [Hash] opts the optional parameters
385
+ # @option opts [String] :src_storage_name Source storage name
386
+ # @option opts [String] :dest_storage_name Destination storage name
387
+ # @return [nil]
388
+ describe 'copy_folder test' do
389
+ it "must be throw if error" do
390
+
391
+ src_path = "HtmlTestDoc/testSourceFolder"
392
+ opts_exist = {storage_name: nil, version_id: nil}
393
+
394
+ # Check before
395
+ res = @api.object_exists(src_path, opts_exist)
396
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
397
+ expect(res.exists).to be false
398
+ expect(res.is_folder).to be false
399
+
400
+ # create folder
401
+ opts_folder = {storage_name: nil}
402
+ @api.create_folder(src_path, opts_folder)
403
+
404
+ # Check creating
405
+ res = @api.object_exists(src_path, opts_exist)
406
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
407
+ expect(res.exists).to be true
408
+ expect(res.is_folder).to be true
409
+
410
+ # Test copy folder
411
+ dest_path = "HtmlTestDoc/CopiedFolder"
412
+ opts_copy = {src_storage_name: nil, dest_storage_name: nil}
413
+
414
+ @api.copy_folder(src_path, dest_path, opts_copy)
415
+
416
+ # Check src after copy
417
+ res = @api.object_exists(src_path, opts_exist)
418
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
419
+ expect(res.exists).to be true
420
+ expect(res.is_folder).to be true
421
+
422
+ # Check dst after copy
423
+ res = @api.object_exists(dest_path, opts_exist)
424
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
425
+ expect(res.exists).to be true
426
+ expect(res.is_folder).to be true
427
+
428
+ # Clear test folder
429
+ opts_delete = {storage_name: nil, recursive: true}
430
+ @api.delete_folder(src_path, opts_delete)
431
+ @api.delete_folder(dest_path, opts_delete)
432
+ end
433
+ end
434
+
435
+ # Move folder
436
+ # @param src_path Folder path to move e.g. &#39;/folder&#39;
437
+ # @param dest_path Destination folder path to move to e.g &#39;/dst&#39;
438
+ # @param [Hash] opts the optional parameters
439
+ # @option opts [String] :src_storage_name Source storage name
440
+ # @option opts [String] :dest_storage_name Destination storage name
441
+ # @return [nil]
442
+ describe 'move_folder test' do
443
+ it "must be throw if error" do
444
+
445
+ src_path = "HtmlTestDoc/testSourceFolder"
446
+ opts_exist = {storage_name: nil, version_id: nil}
447
+
448
+ # Check before
449
+ res = @api.object_exists(src_path, opts_exist)
450
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
451
+ expect(res.exists).to be false
452
+ expect(res.is_folder).to be false
453
+
454
+ # create folder
455
+ opts_folder = {storage_name: nil}
456
+ @api.create_folder(src_path, opts_folder)
457
+
458
+ # Check creating
459
+ res = @api.object_exists(src_path, opts_exist)
460
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
461
+ expect(res.exists).to be true
462
+ expect(res.is_folder).to be true
463
+
464
+ # Test move folder
465
+ dest_path = "HtmlTestDoc/MovedFolder"
466
+ opts_copy = {src_storage_name: nil, dest_storage_name: nil}
467
+
468
+ @api.move_folder(src_path, dest_path, opts_copy)
469
+
470
+ # Check src after copy
471
+ res = @api.object_exists(src_path, opts_exist)
472
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
473
+ expect(res.exists).to be false
474
+ expect(res.is_folder).to be false
475
+
476
+ # Check dst after copy
477
+ res = @api.object_exists(dest_path, opts_exist)
478
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
479
+ expect(res.exists).to be true
480
+ expect(res.is_folder).to be true
481
+
482
+ # Clear test folder
483
+ opts_delete = {storage_name: nil, recursive: true}
484
+ @api.delete_folder(src_path, opts_delete)
485
+ @api.delete_folder(dest_path, opts_delete)
486
+ end
487
+ end
488
+
489
+ # Delete folder
490
+ # @param path Folder path e.g. &#39;/folder&#39;
491
+ # @param [Hash] opts the optional parameters
492
+ # @option opts [String] :storage_name Storage name
493
+ # @option opts [BOOLEAN] :recursive Enable to delete folders, subfolders and files (default to false)
494
+ # @return [nil]
495
+ describe 'delete_folder test' do
496
+ it "must be throw if error" do
497
+
498
+ path = "HtmlTestDoc/testDeketeFolder"
499
+ opts_exist = {storage_name: nil, version_id: nil}
500
+
501
+ # Check before
502
+ res = @api.object_exists(path, opts_exist)
503
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
504
+ expect(res.exists).to be false
505
+ expect(res.is_folder).to be false
506
+
507
+ # create folder
508
+ opts_folder = {storage_name: nil}
509
+ @api.create_folder(path, opts_folder)
510
+
511
+ # Check creating
512
+ res = @api.object_exists(path, opts_exist)
513
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
514
+ expect(res.exists).to be true
515
+ expect(res.is_folder).to be true
516
+
517
+ # Test delete folder
518
+ opts_delete = {storage_name: nil, recursive: true}
519
+ @api.delete_folder(path, opts_delete)
520
+
521
+ # Check after delete
522
+ res = @api.object_exists(path, opts_exist)
523
+ expect(res).to be_an_instance_of AsposeHtml::ObjectExist
524
+ expect(res.exists).to be false
525
+ expect(res.is_folder).to be false
526
+ end
527
+ end
528
+
529
+ # Get all files and folders within a folder
530
+ # @param path Folder path e.g. &#39;/folder&#39;
531
+ # @param [Hash] opts the optional parameters
532
+ # @option opts [String] :storage_name Storage name
533
+ # @return [FilesList]
534
+ describe 'get_files_list test' do
535
+ it "should work" do
536
+ path = "HtmlTestDoc"
537
+ opts = {storage_name: nil}
538
+ res = @api.get_files_list(path, opts)
539
+ puts(res)
540
+ end
541
+ end
542
+ end