Skip to content

Commit c010de6

Browse files
maxnussbaumGERMAN ATTANASIO RUIZ
authored andcommitted
test(discovery): Adjust tests for discovery
1 parent 52a5831 commit c010de6

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

test/integration/test_discovery_v1.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_configurations
7474
end
7575

7676
def test_collections_and_expansions
77+
skip "Time consuming"
7778
name = "Example collection for ruby" + ("A".."Z").to_a.sample
7879
new_collection_id = @service.create_collection(
7980
environment_id: @environment_id,
@@ -131,6 +132,7 @@ def test_collections_and_expansions
131132
end
132133

133134
def test_documents
135+
skip "Time consuming"
134136
add_doc = nil
135137
File.open(Dir.getwd + "/resources/simple.html") do |file_info|
136138
add_doc = @service.add_document(

test/unit/test_discovery_v1.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,15 @@ def test_document
499499
"Host" => "gateway.watsonplatform.net"
500500
}
501501
).to_return(status: 200, body: { body: [] }.to_json, headers: { "Content-Type" => "application/json" })
502+
service_response = service.update_document(
503+
environment_id: "envid",
504+
collection_id: "collid",
505+
document_id: "docid",
506+
file: "file",
507+
filename: "file.name"
508+
)
509+
assert_equal({ "body" => [] }, service_response.body)
510+
502511
service_response = service.update_document(
503512
environment_id: "envid",
504513
collection_id: "collid",
@@ -1107,4 +1116,29 @@ def test_delete_credentials
11071116
)
11081117
assert_equal({ "deleted" => "true" }, service_response.body)
11091118
end
1119+
1120+
def test_update_collection
1121+
service = WatsonAPIs::DiscoveryV1.new(
1122+
username: "username",
1123+
password: "password",
1124+
version: "2018-03-05"
1125+
)
1126+
stub_request(:put, "https://gateway.watsonplatform.net/discovery/api/v1/environments/envid/collections/collid?version=2018-03-05")
1127+
.with(
1128+
body: "{\"name\":\"name\",\"description\":\"updated description\"}",
1129+
headers: {
1130+
"Accept" => "application/json",
1131+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
1132+
"Content-Type" => "application/json",
1133+
"Host" => "gateway.watsonplatform.net"
1134+
}
1135+
).to_return(status: 200, body: { "updated" => "true" }.to_json, headers: { "Content-Type" => "application/json" })
1136+
service_response = service.update_collection(
1137+
environment_id: "envid",
1138+
collection_id: "collid",
1139+
name: "name",
1140+
description: "updated description"
1141+
)
1142+
assert_equal({ "updated" => "true" }, service_response.body)
1143+
end
11101144
end

0 commit comments

Comments
 (0)