Skip to content

Commit bbc5f9e

Browse files
committed
test: refactor unit tests to use default urls
1 parent cfa9447 commit bbc5f9e

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

resources/vcap-testing.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"credentials": {
55
"password": "password",
6-
"url": "https://gateway.watsonplatform.net/personality-insights/api",
6+
"url": "https://gateway-wdc.watsonplatform.net/personality-insights/api",
77
"username": "username"
88
},
99
"label": "personality",

test/unit/test_personality_insights_v3.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def test_plain_to_json
3333
version: "2017-10-13",
3434
authenticator: authenticator
3535
)
36+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
3637
service_response = service.profile(
3738
accept: "application/json",
3839
content: personality_text,
@@ -88,6 +89,7 @@ def test_json_to_json
8889
version: "2017-10-13",
8990
authenticator: authenticator
9091
)
92+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
9193
service_response = service.profile(
9294
accept: "application/json",
9395
content: personality_text,
@@ -128,6 +130,7 @@ def test_json_to_csv
128130
version: "2017-10-13",
129131
authenticator: authenticator
130132
)
133+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
131134
service_response = service.profile(
132135
content: personality_text,
133136
content_type: "application/json",
@@ -171,6 +174,7 @@ def test_plain_to_json_es
171174
version: "2017-10-13",
172175
authenticator: authenticator
173176
)
177+
service.service_url = "https://gateway.watsonplatform.net/personality-insights/api"
174178
service_response = service.profile(
175179
accept: "application/json",
176180
content: personality_text,

test/unit/test_vcap_using_personality_insights.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ def test_plain_to_json
1717
"Content-Type" => "application/json"
1818
}
1919
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: JSON.parse(profile_response), headers: headers)
20-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
20+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
2121
.with(
2222
body: personality_text,
2323
headers: {
2424
"Accept" => "application/json",
2525
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
2626
"Content-Type" => "text/plain;charset=utf-8",
27-
"Host" => "gateway.watsonplatform.net"
27+
"Host" => "gateway-wdc.watsonplatform.net"
2828
}
2929
).to_return(status: 200, body: profile_response, headers: headers)
3030
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -52,14 +52,14 @@ def test_json_to_json
5252
"Content-Type" => "applicaiton/json"
5353
}
5454
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
55-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
55+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
5656
.with(
5757
body: personality_text,
5858
headers: {
5959
"Accept" => "application/json",
6060
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
6161
"Content-Type" => "application/json",
62-
"Host" => "gateway.watsonplatform.net"
62+
"Host" => "gateway-wdc.watsonplatform.net"
6363
}
6464
).to_return(status: 200, body: profile_response, headers: headers)
6565
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -89,14 +89,14 @@ def test_json_to_csv
8989
"Content-Type" => "text/csv"
9090
}
9191
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
92-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
92+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
9393
.with(
9494
body: personality_text,
9595
headers: {
9696
"Accept" => "text/csv",
9797
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
9898
"Content-Type" => "application/json",
99-
"Host" => "gateway.watsonplatform.net"
99+
"Host" => "gateway-wdc.watsonplatform.net"
100100
}
101101
).to_return(status: 200, body: profile_response, headers: headers)
102102
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
@@ -127,7 +127,7 @@ def test_plain_to_json_es
127127
"Content-Type" => "application/json"
128128
}
129129
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
130-
stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
130+
stub_request(:post, "https://gateway-wdc.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
131131
.with(
132132
body: personality_text,
133133
headers: {
@@ -136,7 +136,7 @@ def test_plain_to_json_es
136136
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
137137
"Content-Language" => "es",
138138
"Content-Type" => "text/plain;charset=utf-8",
139-
"Host" => "gateway.watsonplatform.net"
139+
"Host" => "gateway-wdc.watsonplatform.net"
140140
}
141141
).to_return(status: 200, body: profile_response.to_json, headers: headers)
142142
authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")

0 commit comments

Comments
 (0)