Skip to content

Commit a40b69e

Browse files
Merge branch 'WORDSCLOUD-911' into 'master'
range and WNP tests See merge request words-cloud/words-cloud-ruby!1
2 parents 7c4e636 + ba33e17 commit a40b69e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1551
-729
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,5 @@ hs_err_pid*
113113
.idea/*
114114
vendor/*
115115
testReports/*
116+
Gemfile.lock
117+
servercreds.json

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def runtests(dockerImageVersion)
99
try {
1010
stage('checkout'){
1111
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'LocalBranch', localBranch: "**"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-ruby.git']]])
12-
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
12+
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
1313
sh 'mkdir -p Settings'
1414
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\", \\"BaseUrl\\": \\"${testServerUrl}\\"}" > Settings/servercreds.json'
1515
}

Settings/servercreds.json

Whitespace-only changes.
22.5 KB
Binary file not shown.

tests/Common/api_coverage_tests.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# --------------------------------------------------------------------------------------------------------------------
33
# <copyright company="Aspose" file="api_coverage_tests.rb">
4-
# Copyright (c) 2018 Aspose.Words for Cloud
4+
# Copyright (c) 2019 Aspose.Words for Cloud
55
# </copyright>
66
# <summary>
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -35,12 +35,14 @@ def test_api_coverage
3535
require_all '../Common'
3636
require_all '../DocumentActions'
3737
require_all '../DocumentElements'
38+
require_all '../Storage'
39+
require_all '../Range'
3840
arr = [BookmarksTests, AppendDocumentTests, CommentsTests, CompareDocumentTests, ConvertDocumentTests,
3941
DocumentStatisticsTests, DocumentTests, LoadWebDocumentTests, RevisionsTests,
4042
SplitDocumentTests, DocumentPropertiesTests, DocumentProtectionTests, DrawingObjectsTests, FieldsTests,
4143
FormFieldTests, MailMergeFieldsTests, FootnoteTests, HeaderFootersTests, HyperlinksTests, MacrosTests,
42-
ExecuteMailMergeTests, ExecuteTemplateTests, MathObjectsTests, PagesTests, ParagraphsTests, RunsTests,
43-
SectionsTests, TablesTests, TextTests, WatermarkTests, FontCacheTests, ClassificationTests]
44+
ExecuteMailMergeTests, MathObjectsTests, PagesTests, ParagraphsTests, RunsTests,
45+
SectionsTests, TablesTests, TextTests, WatermarkTests, FontCacheTests, ClassificationTests, FileTests, FolderTests, RangeTests]
4446
test_methods = []
4547
arr.each {|el| (test_methods << el.instance_methods(false).select{ |m| /test_folder/ !~ m}).flatten! }
4648
methods = @words_api.public_methods(false).select {|m| /api_client/ !~ m }.map {|m| m.to_s}

tests/Common/error_handling_tests.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# --------------------------------------------------------------------------------------------------------------------
33
# <copyright company="Aspose" file="error_handling_tests.rb">
4-
# Copyright (c) 2018 Aspose.Words for Cloud
4+
# Copyright (c) 2019 Aspose.Words for Cloud
55
# </copyright>
66
# <summary>
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -37,9 +37,10 @@ def test_handle_server_errors
3737
begin
3838
@words_api.get_section request
3939
assert_throws 'FAILED'
40+
rescue ApiError => e
41+
assert_equal 404, e.code
42+
rescue
4043
end
41-
rescue ApiError => e
42-
assert_equal 400, e.code
4344
end
4445
end
4546
end

tests/Common/font_cache_tests.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# --------------------------------------------------------------------------------------------------------------------
33
# <copyright company="Aspose" file="reset_cache_tests.rb">
4-
# Copyright (c) 2018 Aspose.Words for Cloud
4+
# Copyright (c) 2019 Aspose.Words for Cloud
55
# </copyright>
66
# <summary>
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -34,7 +34,6 @@ class FontCacheTests < BaseTestContext
3434
def test_reset_cache
3535
request = ResetCacheRequest.new
3636
result = @words_api.reset_cache request
37-
assert_equal 200, result.code
3837
end
3938

4039
#
@@ -43,7 +42,7 @@ def test_reset_cache
4342
def test_get_available_fonts
4443
request = GetAvailableFontsRequest.new
4544
result = @words_api.get_available_fonts request
46-
assert_equal 200, result.code
45+
assert_equal FALSE, result.nil?
4746
end
4847
end
4948
end
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#
2+
# --------------------------------------------------------------------------------------------------------------------
3+
# <copyright company="Aspose" file="missing_credentials_tests.rb">
4+
# Copyright (c) 2019 Aspose.Words for Cloud
5+
# </copyright>
6+
# <summary>
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
# </summary>
25+
# --------------------------------------------------------------------------------------------------------------------
26+
#
27+
module AsposeWordsCloud
28+
require_relative '../base_test_context'
29+
class MissingCredentialsTests < BaseTestContext
30+
alias :super_setup :setup
31+
def setup
32+
File.rename('Settings/servercreds.json', 'Settings/servercreds1.json');
33+
end
34+
35+
def teardown
36+
File.rename('Settings/servercreds1.json', 'Settings/servercreds.json');
37+
end
38+
39+
#
40+
# Test for base class throwing exception if credentials file is missing
41+
def test_missing_credentials
42+
begin
43+
super_setup()
44+
assert_throws 'FAILED'
45+
rescue ArgumentError => e
46+
puts e.inspect
47+
else
48+
assert_throws 'FAILED'
49+
end
50+
end
51+
end
52+
end
53+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#
2+
# --------------------------------------------------------------------------------------------------------------------
3+
# <copyright company="Aspose" file="token_expires_tests.rb">
4+
# Copyright (c) 2019 Aspose.Words for Cloud
5+
# </copyright>
6+
# <summary>
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
# </summary>
25+
# --------------------------------------------------------------------------------------------------------------------
26+
#
27+
module AsposeWordsCloud
28+
require_relative '../base_test_context'
29+
class TokenExpiresTests < BaseTestContext
30+
31+
#
32+
# Test for client automatically updates token if expired
33+
#
34+
def test_token_expires
35+
@words_api.api_client.config.access_token = 'eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE1Njc1ODg2OTksImV4cCI6MTU2NzY3NTA5OSwiaXNzIjoiaHR0cHM6Ly9hcGktcWEuYXNwb3NlLmNsb3VkIiwiYXVkIjpbImh0dHBzOi8vYXBpLXFhLmFzcG9zZS5jbG91ZC9yZXNvdXJjZXMiLCJhcGkucGxhdGZvcm0iLCJhcGkucHJvZHVjdHMiXSwiY2xpZW50X2lkIjoiNzhCNjM3RjYtQjRDQy00MURFLUE2MTktRDhCRDlGQzJCNkI2IiwiY2xpZW50X2lkU3J2SWQiOiIiLCJzY29wZSI6WyJhcGkucGxhdGZvcm0iLCJhcGkucHJvZHVjdHMiXX0.NcsvIWr8zpHIGKTtVQIevRUJchTc2NqwgjNIVg3J9uXowr6lbsLgV6v4KsVlR6yssjkfjZEsRNOExaxdga7Mrv6RvXhgZDs5-_6HrtMdIHUe_1F5kbS5Cz1evyOeQhfdeRnZWHR-BZOAzyB__1gXBo2MObPF3NIt6j6vPWbHU9DSLrjEWPCULVdmLtl6-NDYHvNR4AbiaH-qfU8j1bMLdBfyzK2uX376EpbinSZHeNeFp4dOOhAOpDR-p_kCt4O4z5Tjrcuyw9PrCBmyHWwMSa-8g95Jy-_d89VAZvS1xEFHNX_hZilEPseGPUzDMwg_oOIBfIVcRS3NxqWvEWof7A';
36+
request = ClassifyRequest.new "Try text classification", "3"
37+
result = @words_api.classify request
38+
39+
assert_equal false, result.nil?
40+
end
41+
end
42+
end
43+

tests/Document/document_tests.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# --------------------------------------------------------------------------------------------------------------------
33
# <copyright company="Aspose" file="document_tests.rb">
4-
# Copyright (c) 2018 Aspose.Words for Cloud
4+
# Copyright (c) 2019 Aspose.Words for Cloud
55
# </copyright>
66
# <summary>
77
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -37,28 +37,26 @@ def test_folder
3737
def test_get_document
3838
filename = 'test_multi_pages.docx'
3939
remote_name = 'TestGetDocument.docx'
40+
remote_path = File.join(test_folder, remote_name)
41+
upload_file File.join(local_common_folder, filename), remote_path
4042

41-
st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, "r").read
42-
@storage_api.put_create st_request
43-
44-
request = GetDocumentRequest.new remote_name, remote_test_folder + test_folder
43+
request = GetDocumentRequest.new remote_name, test_folder
4544
result = @words_api.get_document request
46-
assert_equal 200, result.code
45+
assert_equal false, result.document.nil?
4746
end
4847

4948
#
5049
# Test for creating document
5150
#
52-
def test_put_create_document
51+
def test_create_document
5352
filename = 'test_multi_pages.docx'
54-
remote_name = 'TestPutCreateDocument.docx'
53+
remote_name = 'TestCreateDocument.docx'
5554

56-
st_request = PutCreateRequest.new remote_test_folder + test_folder + '/' + remote_name, File.open(local_common_folder + filename, "r").read
57-
@storage_api.put_create st_request
55+
upload_file(local_common_folder + filename, remote_test_folder + test_folder + '/' + remote_name)
5856

59-
request = PutCreateDocumentRequest.new nil, remote_name, remote_test_folder + test_folder
60-
result = @words_api.put_create_document request
61-
assert_equal 200, result.code
57+
request = CreateDocumentRequest.new nil, remote_name, remote_test_folder + test_folder
58+
result = @words_api.create_document request
59+
assert_equal false, result.document.nil?
6260
end
6361
end
6462
end

0 commit comments

Comments
 (0)