Skip to content

Commit

Permalink
Added tests with abuse types specified
Browse files Browse the repository at this point in the history
  • Loading branch information
atpaino committed Aug 2, 2018
1 parent c1bf6c2 commit 56158e0
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions spec/unit/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,28 @@ def fully_qualified_api_endpoint
end


it "Successfully executes client.get_user_score() with abuse types specified" do
api_key = "foobar"
response_json = user_score_response_json

stub_request(:get, "https://api.siftscience.com/v205/users/247019/score" +
"?api_key=foobar&abuse_types=content_abuse,payment_abuse")
.to_return(:status => 200, :body => MultiJson.dump(response_json),
:headers => {"content-type"=>"application/json; charset=UTF-8",
"content-length"=> "74"})

response = Sift::Client.new(:api_key => api_key).get_user_score(user_score_response_json[:entity_id],
:abuse_types => ["content_abuse",
"payment_abuse"])
expect(response.ok?).to eq(true)
expect(response.api_status).to eq(0)
expect(response.api_error_message).to eq("OK")

expect(response.body["entity_id"]).to eq("247019")
expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78)
end


it "Successfully executes client.rescore_user()" do
api_key = "foobar"
response_json = user_score_response_json
Expand All @@ -342,6 +364,28 @@ def fully_qualified_api_endpoint
end


it "Successfully executes client.rescore_user() with abuse types specified" do
api_key = "foobar"
response_json = user_score_response_json

stub_request(:post, "https://api.siftscience.com/v205/users/247019/score" +
"?api_key=foobar&abuse_types=content_abuse,payment_abuse")
.to_return(:status => 200, :body => MultiJson.dump(response_json),
:headers => {"content-type"=>"application/json; charset=UTF-8",
"content-length"=> "74"})

response = Sift::Client.new(:api_key => api_key).rescore_user(user_score_response_json[:entity_id],
:abuse_types => ["content_abuse",
"payment_abuse"])
expect(response.ok?).to eq(true)
expect(response.api_status).to eq(0)
expect(response.api_error_message).to eq("OK")

expect(response.body["entity_id"]).to eq("247019")
expect(response.body["scores"]["payment_abuse"]["score"]).to eq(0.78)
end


it "Successfully make a sync score request" do
api_key = "foobar"
response_json = {
Expand Down

0 comments on commit 56158e0

Please sign in to comment.