impermium 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE.txt +20 -0
- data/README.md +118 -0
- data/Rakefile +7 -0
- data/impermium.gemspec +31 -0
- data/lib/faraday/raise_4xx.rb +18 -0
- data/lib/impermium/client.rb +57 -0
- data/lib/impermium/configuration.rb +44 -0
- data/lib/impermium/content/blog_post.rb +38 -0
- data/lib/impermium/content/bookmark.rb +47 -0
- data/lib/impermium/content/comment.rb +38 -0
- data/lib/impermium/content/connection.rb +42 -0
- data/lib/impermium/content/listing.rb +37 -0
- data/lib/impermium/content.rb +15 -0
- data/lib/impermium/errors.rb +25 -0
- data/lib/impermium/user/account.rb +50 -0
- data/lib/impermium/user/profile.rb +35 -0
- data/lib/impermium/user.rb +9 -0
- data/lib/impermium/version.rb +3 -0
- data/lib/impermium.rb +20 -0
- data/spec/.gitignore +1 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_blog_post_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_post_id.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_post_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_blog_url.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_enduser_ip.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/missing_arguments/missing_user_id.yml +43 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_method/successful_blog_post_request.yml +39 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_blog_post_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/blog_post_object/blog_post_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_bookmark_url.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_like_value.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_like_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_bookmark_url.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_bookmark_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/bookmark_object/bookmark_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_article_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_comment_permalink.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_enduser_ip.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/missing_arguments/missing_user_id.yml +43 -0
- data/spec/cassettes/content_API_section/comment_object/comment_method/successful_request.yml +39 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_comment_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/comment_object/comment_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/invalid_operation_value.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_requester_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/missing_arguments/missing_responder_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_follow_connection_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_follow_connection_response.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_friend_connection_request.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_method/successful_friend_connection_response.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/invalid_connection_type_value.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_connection_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_connection_type.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/connection_object/connection_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_content.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_listing_permalink.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_method/successful_request.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_listing_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/content_API_section/listing_object/listing_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/missing_arguments/missing_analyst_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_analyst_feedback_method/successful_account_analyst_feedback_method_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_attempt_method/missing_arguments.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_attempt_method/successful_account_attempt_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_login_method/successful_account_login_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_method/successful_account_method_request.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/account_object/account_user_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_analyst_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/missing_params/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_analyst_feedback_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_enduser_ip.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/missing_arguments/missing_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_method/successful_request.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/invalid_reporter_user_type.yml +38 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_desired_result.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_profile_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_reporter_ip.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/missing_arguments/missing_reporter_user_id.yml +42 -0
- data/spec/cassettes/user_API_section/profile_object/profile_user_feedback_method/successful_request.yml +38 -0
- data/spec/configuration.yml.sample +3 -0
- data/spec/impermium/client_spec.rb +67 -0
- data/spec/impermium/content/blog_post_spec.rb +173 -0
- data/spec/impermium/content/bookmark_spec.rb +205 -0
- data/spec/impermium/content/comment_spec.rb +178 -0
- data/spec/impermium/content/connection_spec.rb +257 -0
- data/spec/impermium/content/listing_spec.rb +169 -0
- data/spec/impermium/user/account_spec.rb +184 -0
- data/spec/impermium/user/profile_spec.rb +154 -0
- data/spec/spec_helper.rb +32 -0
- metadata +433 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "client configuration" do
|
4
|
+
|
5
|
+
describe "default configuration" do
|
6
|
+
before(:each) do
|
7
|
+
@keys = Impermium::Configuration::VALID_CONFIG_KEYS
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should support current API version: 3.1" do
|
11
|
+
client = Impermium.new
|
12
|
+
client.api_version.should == '3.1'
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "configuration attributes" do
|
16
|
+
it "should have configuration read attributes" do
|
17
|
+
client = Impermium.new
|
18
|
+
@keys.each { |key| client.respond_to?(key).should be_true }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have configuration write attributes" do
|
22
|
+
client = Impermium.new
|
23
|
+
@keys.each { |key| client.respond_to?("#{key}=").should be_true }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should correctly set values through attributes" do
|
27
|
+
client = Impermium.new
|
28
|
+
@keys.each do |key|
|
29
|
+
client.send("#{key}=", key)
|
30
|
+
end
|
31
|
+
|
32
|
+
@keys.each do |key|
|
33
|
+
client.send(key).should == key
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "through initialization" do
|
39
|
+
before(:each) do
|
40
|
+
@config = {
|
41
|
+
:adapter => "some_adapter",
|
42
|
+
:api_version => "0.1",
|
43
|
+
:api_key => "impermium_key_001",
|
44
|
+
:client_name => "Impermium Client",
|
45
|
+
:client_id => "Client ID",
|
46
|
+
:endpoint => "http://our.test.endpoint.com"
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should set values to those passed during initialization" do
|
51
|
+
client = Impermium::Client.new(@config)
|
52
|
+
@config.each do |k, v|
|
53
|
+
client.send("#{k}").should == v
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "URL composing" do
|
60
|
+
it "should contain passed path in the api URL" do
|
61
|
+
path = "some/request/path/"
|
62
|
+
client = Impermium.new(:api_key => "test_api_key")
|
63
|
+
client.api_url(path).should include(path)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "content API section" do
|
5
|
+
describe "blog_post object" do
|
6
|
+
before(:each) do
|
7
|
+
@user_id = "whi345"
|
8
|
+
@analyst_id = "4n4l1s7"
|
9
|
+
@reporter_user_id = "r3p0rt3r"
|
10
|
+
@ip = "1.1.1.1"
|
11
|
+
@content = "just a simple post"
|
12
|
+
@post_id = "just-a-post#984721"
|
13
|
+
@permalink = "http://example.com/2012/03/05/just_a_post"
|
14
|
+
@url = "http://example.com"
|
15
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "blog_post method" do
|
19
|
+
describe "missing arguments" do
|
20
|
+
|
21
|
+
context "missing user_id" do
|
22
|
+
use_vcr_cassette
|
23
|
+
it "should raise BadRequest error" do
|
24
|
+
lambda { Impermium.blog_post(nil, @post_id, @content, @permalink, @url, @ip) }.should raise_error(Impermium::BadRequest, /user_id/)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "missing blog_post_id" do
|
29
|
+
use_vcr_cassette
|
30
|
+
it "should raise BadRequest error" do
|
31
|
+
lambda { Impermium.blog_post(@user_id, nil, @content, @permalink, @url, @ip) }.should raise_error(Impermium::BadRequest, /blog_post_id/)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "missing content" do
|
36
|
+
use_vcr_cassette
|
37
|
+
it "should raise BadRequest error" do
|
38
|
+
lambda { Impermium.blog_post(@user_id, @post_id, nil, @permalink, @url, @ip) }.should raise_error(Impermium::BadRequest, /content/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "missing blog_post_permalink" do
|
43
|
+
use_vcr_cassette
|
44
|
+
it "should raise BadRequest error" do
|
45
|
+
lambda { Impermium.blog_post(@user_id, @post_id, @content, nil, @url, @ip) }.should raise_error(Impermium::BadRequest, /blog_post_permalink/)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "missing blog_url" do
|
50
|
+
use_vcr_cassette
|
51
|
+
it "should raise BadRequest error" do
|
52
|
+
lambda { Impermium.blog_post(@user_id, @post_id, @content, @permalink, nil, @ip) }.should raise_error(Impermium::BadRequest, /blog_url/)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "missing enduser_ip" do
|
57
|
+
use_vcr_cassette
|
58
|
+
it "should raise BadRequest error" do
|
59
|
+
lambda { Impermium.blog_post(@user_id, @post_id, @content, @permalink, @url, nil) }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "successful blog_post request" do
|
65
|
+
use_vcr_cassette
|
66
|
+
it "should mark blog post with 'notspam' label" do
|
67
|
+
res = Impermium.blog_post(@user_id, @post_id, @content, @permalink, @url, @ip)
|
68
|
+
res.spam_classifier.label.should == "notspam"
|
69
|
+
res.spam_classifier.score.to_f.should < 0.4
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "blog_post_analyst_feedback method" do
|
75
|
+
describe "missing arguments" do
|
76
|
+
context "missing analyst_id" do
|
77
|
+
use_vcr_cassette
|
78
|
+
it "should raise BadRequest error" do
|
79
|
+
lambda { Impermium.blog_post_analyst_feedback(nil, @post_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context "missing blog_post_id" do
|
84
|
+
use_vcr_cassette
|
85
|
+
it "should raise BadRequest error" do
|
86
|
+
lambda { Impermium.blog_post_analyst_feedback(@analyst_id, nil, @desired_result) }.should raise_error(Impermium::BadRequest, /blog_post_id/)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "missing desired_result" do
|
91
|
+
use_vcr_cassette
|
92
|
+
it "should raise BadRequest error" do
|
93
|
+
lambda { Impermium.blog_post_analyst_feedback(@analyst_id, @post_id, nil) }.should raise_error(Impermium::BadRequest, /desired_result/)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "successful request" do
|
99
|
+
use_vcr_cassette
|
100
|
+
it "should return an OK response" do
|
101
|
+
res = Impermium.blog_post_analyst_feedback(@analyst_id, @post_id, @desired_result)
|
102
|
+
res.response_id.should be_true
|
103
|
+
res.timestamp.should be_true
|
104
|
+
res.status.should be_nil
|
105
|
+
res.message.should be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "blog_post_user_feedback method" do
|
111
|
+
describe "missing arguments" do
|
112
|
+
context "missing reporter_user_id" do
|
113
|
+
use_vcr_cassette
|
114
|
+
it "should raise BadRequest error" do
|
115
|
+
lambda { Impermium.blog_post_user_feedback(nil, "MODERATOR",
|
116
|
+
@ip, @post_id, @desired_result)
|
117
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "invalid reporter_user_type" do
|
122
|
+
use_vcr_cassette
|
123
|
+
it "should use default value" do
|
124
|
+
res = Impermium.blog_post_user_feedback(@reporter_user_id, "NOT VALID", @ip, @post_id, @desired_result)
|
125
|
+
res.response_id.should be
|
126
|
+
res.timestamp.should be
|
127
|
+
res.status.should be_nil
|
128
|
+
res.message.should be_nil
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "missing reporter_ip" do
|
133
|
+
use_vcr_cassette
|
134
|
+
it "should raise BadRequest error" do
|
135
|
+
lambda { Impermium.blog_post_user_feedback(@reporter_user_id, "MODERATOR",
|
136
|
+
"", @post_id, @desired_result)
|
137
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "missing blog_post_id" do
|
142
|
+
use_vcr_cassette
|
143
|
+
it "should raise BadRequest error" do
|
144
|
+
lambda { Impermium.blog_post_user_feedback(@reporter_user_id, "MODERATOR",
|
145
|
+
@ip, nil, @desired_result)
|
146
|
+
}.should raise_error(Impermium::BadRequest, /blog_post_id/)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "missing desired_result" do
|
151
|
+
use_vcr_cassette
|
152
|
+
it "should raise BadRequest error" do
|
153
|
+
lambda { Impermium.blog_post_user_feedback(@reporter_user_id, "MODERATOR",
|
154
|
+
@ip, @post_id, nil)
|
155
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "successful request" do
|
161
|
+
use_vcr_cassette
|
162
|
+
it "should return an OK response" do
|
163
|
+
res = Impermium.blog_post_user_feedback(@reporter_user_id, "ENDUSER", @ip, @post_id, @desired_result)
|
164
|
+
res.response_id.start_with?("CLID").should be_true
|
165
|
+
res.response_id.should be
|
166
|
+
res.timestamp.should be
|
167
|
+
res.status.should be_nil
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "content API section" do
|
5
|
+
describe "bookmark object" do
|
6
|
+
before(:each) do
|
7
|
+
@user_id = "whi777"
|
8
|
+
@analyst_id = "4n4l1s7_ID"
|
9
|
+
@reporter_user_id = "r3p0rt3r_ID"
|
10
|
+
@ip = "2.2.2.2"
|
11
|
+
@bookmark_id = "b00km4rk_ID"
|
12
|
+
@bookmark_url = "http://example.com/category/book/marks/33?query=whi"
|
13
|
+
@like_value = "1"
|
14
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "bookmark method" do
|
18
|
+
describe "missing arguments" do
|
19
|
+
|
20
|
+
context "missing user_id" do
|
21
|
+
use_vcr_cassette
|
22
|
+
it "should raise BadRequest error" do
|
23
|
+
lambda { Impermium.bookmark(nil, @bookmark_id, @bookmark_url, @ip) }.should raise_error(Impermium::BadRequest, /user_id/)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "missing bookmark_id" do
|
28
|
+
use_vcr_cassette
|
29
|
+
it "should raise BadRequest error" do
|
30
|
+
lambda { Impermium.bookmark(@user_id, nil, @bookmark_url, @ip) }.should raise_error(Impermium::BadRequest, /bookmark_id/)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "missing bookmark_url" do
|
35
|
+
use_vcr_cassette
|
36
|
+
it "should raise BadRequest error" do
|
37
|
+
lambda { Impermium.bookmark(@user_id, @bookmark_id, nil, @ip) }.should raise_error(Impermium::BadRequest, /bookmark_url/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "missing enduser_ip" do
|
42
|
+
use_vcr_cassette
|
43
|
+
it "should raise BadRequest error" do
|
44
|
+
lambda { Impermium.bookmark(@user_id, @bookmark_id, @bookmark_url, nil) }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "successful request" do
|
50
|
+
use_vcr_cassette
|
51
|
+
it "should mark bookmark with 'notspam' label" do
|
52
|
+
res = Impermium.bookmark(@user_id, @bookmark_id, @bookmark_url, @ip)
|
53
|
+
res.spam_classifier.label.should == "notspam"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "bookmark_like method" do
|
59
|
+
describe "missing arguments" do
|
60
|
+
|
61
|
+
context "missing user_id" do
|
62
|
+
use_vcr_cassette
|
63
|
+
it "should raise BadRequest error" do
|
64
|
+
lambda { Impermium.bookmark_like(nil, @bookmark_id, @bookmark_url, @like_value, @ip) }.should raise_error(Impermium::BadRequest, /user_id/)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context "missing bookmark_id" do
|
69
|
+
use_vcr_cassette
|
70
|
+
it "should raise BadRequest error" do
|
71
|
+
lambda { Impermium.bookmark_like(@user_id, nil, @bookmark_url, @like_value, @ip) }.should raise_error(Impermium::BadRequest, /bookmark_id/)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "missing bookmark_url" do
|
76
|
+
use_vcr_cassette
|
77
|
+
it "should raise BadRequest error" do
|
78
|
+
lambda { Impermium.bookmark_like(@user_id, @bookmark_id, nil, @like_value, @ip) }.should raise_error(Impermium::BadRequest, /bookmark_url/)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context "missing like_value" do
|
83
|
+
use_vcr_cassette
|
84
|
+
it "should raise BadRequest error" do
|
85
|
+
lambda { Impermium.bookmark_like(@user_id, @bookmark_id, @bookmark_url, nil, @ip) }.should raise_error(Impermium::BadRequest, /like_value/)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "missing enduser_ip" do
|
90
|
+
use_vcr_cassette
|
91
|
+
it "should raise BadRequest error" do
|
92
|
+
lambda { Impermium.bookmark_like(@user_id, @bookmark_id, @bookmark_url, @like_value, nil) }.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "successful request" do
|
98
|
+
use_vcr_cassette
|
99
|
+
it "should mark like with 'notspam' label" do
|
100
|
+
res = Impermium.bookmark_like(@user_id, @bookmark_id, @bookmark_url, @like_value, @ip)
|
101
|
+
res.spam_classifier.label.should == "notspam"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "bookmark_analyst_feedback method" do
|
107
|
+
describe "missing arguments" do
|
108
|
+
context "missing analyst_id" do
|
109
|
+
use_vcr_cassette
|
110
|
+
it "should raise BadRequest error" do
|
111
|
+
lambda { Impermium.bookmark_analyst_feedback(nil, @bookmark_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
context "missing bookmark_id" do
|
116
|
+
use_vcr_cassette
|
117
|
+
it "should raise BadRequest error" do
|
118
|
+
lambda { Impermium.bookmark_analyst_feedback(@analyst_id, nil, @desired_result) }.should raise_error(Impermium::BadRequest, /bookmark_id/)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
context "missing desired_result" do
|
123
|
+
use_vcr_cassette
|
124
|
+
it "should raise BadRequest error" do
|
125
|
+
lambda { Impermium.bookmark_analyst_feedback(@analyst_id, @bookmark_id, nil) }.should raise_error(Impermium::BadRequest, /desired_result/)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "successful request" do
|
131
|
+
use_vcr_cassette
|
132
|
+
it "should return an OK response" do
|
133
|
+
res = Impermium.bookmark_analyst_feedback(@analyst_id, @bookmark_id, @desired_result)
|
134
|
+
res.response_id.should be_true
|
135
|
+
res.timestamp.should be_true
|
136
|
+
res.status.should be_nil
|
137
|
+
res.message.should be_nil
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "bookmark_user_feedback method" do
|
143
|
+
describe "missing arguments" do
|
144
|
+
context "missing reporter_user_id" do
|
145
|
+
use_vcr_cassette
|
146
|
+
it "should raise BadRequest error" do
|
147
|
+
lambda { Impermium.bookmark_user_feedback(nil, "MODERATOR",
|
148
|
+
@ip, @bookmark_id, @desired_result)
|
149
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context "invalid reporter_user_type" do
|
154
|
+
use_vcr_cassette
|
155
|
+
it "should use default value" do
|
156
|
+
res = Impermium.bookmark_user_feedback(@reporter_user_id, "NOT VALID", @ip, @bookmark_id, @desired_result)
|
157
|
+
res.response_id.should be
|
158
|
+
res.timestamp.should be
|
159
|
+
res.status.should be_nil
|
160
|
+
res.message.should be_nil
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "missing reporter_ip" do
|
165
|
+
use_vcr_cassette
|
166
|
+
it "should raise BadRequest error" do
|
167
|
+
lambda { Impermium.bookmark_user_feedback(@reporter_user_id, "MODERATOR",
|
168
|
+
"", @bookmark_id, @desired_result)
|
169
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
context "missing bookmark_id" do
|
174
|
+
use_vcr_cassette
|
175
|
+
it "should raise BadRequest error" do
|
176
|
+
lambda { Impermium.bookmark_user_feedback(@reporter_user_id, "MODERATOR",
|
177
|
+
@ip, nil, @desired_result)
|
178
|
+
}.should raise_error(Impermium::BadRequest, /bookmark_id/)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
context "missing desired_result" do
|
183
|
+
use_vcr_cassette
|
184
|
+
it "should raise BadRequest error" do
|
185
|
+
lambda { Impermium.bookmark_user_feedback(@reporter_user_id, "MODERATOR",
|
186
|
+
@ip, @bookmark_id, nil)
|
187
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
describe "successful request" do
|
193
|
+
use_vcr_cassette
|
194
|
+
it "should return an OK response" do
|
195
|
+
res = Impermium.bookmark_user_feedback(@reporter_user_id, "ENDUSER", @ip, @bookmark_id, @desired_result)
|
196
|
+
res.response_id.start_with?("CLID").should be_true
|
197
|
+
res.response_id.should be
|
198
|
+
res.timestamp.should be
|
199
|
+
res.status.should be_nil
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
describe "content API section" do
|
5
|
+
describe "comment object" do
|
6
|
+
before(:each) do
|
7
|
+
@user_id = "whi345"
|
8
|
+
@analyst_id = "4n4l1s7"
|
9
|
+
@reporter_user_id = "r3p0rt3r"
|
10
|
+
@ip = "1.1.1.1"
|
11
|
+
@content = "a simple comment"
|
12
|
+
@comment_id = "simple-comment-347865"
|
13
|
+
@comment_permalink = "http://example.com/2012/03/05/just_a_comment"
|
14
|
+
@article_permalink = "http://example.com/2012/01/05/just_a_post"
|
15
|
+
@desired_result = {:spam_classifier => { :label => "notspam" }}
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "comment method" do
|
19
|
+
describe "missing arguments" do
|
20
|
+
|
21
|
+
context "missing user_id" do
|
22
|
+
use_vcr_cassette
|
23
|
+
it "should raise BadRequest error" do
|
24
|
+
lambda { Impermium.comment(nil, @comment_id, @content, @comment_permalink, @article_permalink, @ip)
|
25
|
+
}.should raise_error(Impermium::BadRequest, /user_id/)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "missing comment_id" do
|
30
|
+
use_vcr_cassette
|
31
|
+
it "should raise BadRequest error" do
|
32
|
+
lambda { Impermium.comment(@user_id, nil, @content, @comment_permalink, @article_permalink, @ip)
|
33
|
+
}.should raise_error(Impermium::BadRequest, /comment_id/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "missing content" do
|
38
|
+
use_vcr_cassette
|
39
|
+
it "should raise BadRequest error" do
|
40
|
+
lambda { Impermium.comment(@user_id, @comment_id, nil, @comment_permalink, @article_permalink, @ip)
|
41
|
+
}.should raise_error(Impermium::BadRequest, /content/)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "missing comment_permalink" do
|
46
|
+
use_vcr_cassette
|
47
|
+
it "should raise BadRequest error" do
|
48
|
+
lambda { Impermium.comment(@user_id, @comment_id, @content, nil, @article_permalink, @ip)
|
49
|
+
}.should raise_error(Impermium::BadRequest, /comment_permalink/)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "missing article_permalink" do
|
54
|
+
use_vcr_cassette
|
55
|
+
it "should raise BadRequest error" do
|
56
|
+
lambda { Impermium.comment(@user_id, @comment_id, @content, @comment_permalink, nil, @ip)
|
57
|
+
}.should raise_error(Impermium::BadRequest, /article_permalink/)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
context "missing enduser_ip" do
|
62
|
+
use_vcr_cassette
|
63
|
+
it "should raise BadRequest error" do
|
64
|
+
lambda { Impermium.comment(@user_id, @comment_id, @content, @comment_permalink, @article_permalink, nil)
|
65
|
+
}.should raise_error(Impermium::BadRequest, /enduser_ip/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "successful request" do
|
71
|
+
use_vcr_cassette
|
72
|
+
it "should mark comment with 'notspam' label" do
|
73
|
+
res = Impermium.comment(@user_id, @comment_id, @content, @comment_permalink, @article_permalink, @ip)
|
74
|
+
res.spam_classifier.label.should == "notspam"
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "comment_analyst_feedback method" do
|
80
|
+
describe "missing arguments" do
|
81
|
+
context "missing analyst_id" do
|
82
|
+
use_vcr_cassette
|
83
|
+
it "should raise BadRequest error" do
|
84
|
+
lambda { Impermium.comment_analyst_feedback(nil, @comment_id, @desired_result) }.should raise_error(Impermium::BadRequest, /analyst_id/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "missing comment_id" do
|
89
|
+
use_vcr_cassette
|
90
|
+
it "should raise BadRequest error" do
|
91
|
+
lambda { Impermium.comment_analyst_feedback(@analyst_id, nil, @desired_result) }.should raise_error(Impermium::BadRequest, /comment_id/)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
context "missing desired_result" do
|
96
|
+
use_vcr_cassette
|
97
|
+
it "should raise BadRequest error" do
|
98
|
+
lambda { Impermium.comment_analyst_feedback(@analyst_id, @comment_id, nil) }.should raise_error(Impermium::BadRequest, /desired_result/)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "successful request" do
|
104
|
+
use_vcr_cassette
|
105
|
+
it "should return an OK response" do
|
106
|
+
res = Impermium.comment_analyst_feedback(@analyst_id, @comment_id, @desired_result)
|
107
|
+
res.response_id.should be_true
|
108
|
+
res.timestamp.should be_true
|
109
|
+
res.status.should be_nil
|
110
|
+
res.message.should be_nil
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "comment_user_feedback method" do
|
116
|
+
describe "missing arguments" do
|
117
|
+
context "missing reporter_user_id" do
|
118
|
+
use_vcr_cassette
|
119
|
+
it "should raise BadRequest error" do
|
120
|
+
lambda { Impermium.comment_user_feedback(nil, "MODERATOR",
|
121
|
+
@ip, @comment_id, @desired_result)
|
122
|
+
}.should raise_error(Impermium::BadRequest, /reporter_user_id/)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
context "invalid reporter_user_type" do
|
127
|
+
use_vcr_cassette
|
128
|
+
it "should use default value" do
|
129
|
+
res = Impermium.comment_user_feedback(@reporter_user_id, "NOT VALID", @ip, @comment_id, @desired_result)
|
130
|
+
res.response_id.should be
|
131
|
+
res.timestamp.should be
|
132
|
+
res.status.should be_nil
|
133
|
+
res.message.should be_nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "missing reporter_ip" do
|
138
|
+
use_vcr_cassette
|
139
|
+
it "should raise BadRequest error" do
|
140
|
+
lambda { Impermium.comment_user_feedback(@reporter_user_id, "MODERATOR",
|
141
|
+
"", @comment_id, @desired_result)
|
142
|
+
}.should raise_error(Impermium::BadRequest, /reporter_ip/)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "missing comment_id" do
|
147
|
+
use_vcr_cassette
|
148
|
+
it "should raise BadRequest error" do
|
149
|
+
lambda { Impermium.comment_user_feedback(@reporter_user_id, "MODERATOR",
|
150
|
+
@ip, nil, @desired_result)
|
151
|
+
}.should raise_error(Impermium::BadRequest, /comment_id/)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "missing desired_result" do
|
156
|
+
use_vcr_cassette
|
157
|
+
it "should raise BadRequest error" do
|
158
|
+
lambda { Impermium.comment_user_feedback(@reporter_user_id, "MODERATOR",
|
159
|
+
@ip, @comment_id, nil)
|
160
|
+
}.should raise_error(Impermium::BadRequest, /desired_result/)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe "successful request" do
|
166
|
+
use_vcr_cassette
|
167
|
+
it "should return an OK response" do
|
168
|
+
res = Impermium.comment_user_feedback(@reporter_user_id, "ENDUSER", @ip, @comment_id, @desired_result)
|
169
|
+
res.response_id.start_with?("CLID").should be_true
|
170
|
+
res.response_id.should be
|
171
|
+
res.timestamp.should be
|
172
|
+
res.status.should be_nil
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|