facebook_test_users 0.0.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +62 -3
- data/bin/fbtu +1 -1
- data/facebook_test_users.gemspec +6 -4
- data/lib/facebook_test_users/app.rb +29 -13
- data/lib/facebook_test_users/cli.rb +209 -41
- data/lib/facebook_test_users/user.rb +25 -5
- data/lib/facebook_test_users/version.rb +1 -1
- data/spec/fbtu/apps/add_user_spec.rb +61 -0
- data/spec/fbtu/apps/register_spec.rb +36 -0
- data/spec/fbtu/apps/rm_user_spec.rb +42 -0
- data/spec/fbtu/apps_spec.rb +3 -1
- data/spec/fbtu/users/change_spec.rb +46 -0
- data/spec/fbtu/users/create_spec.rb +50 -0
- data/spec/fbtu/users/friend_spec.rb +3 -3
- data/spec/fbtu/users/list_apps_spec.rb +56 -0
- data/spec/fbtu/users/list_spec.rb +1 -1
- data/spec/fbtu/users/nuke_spec.rb +1 -1
- data/spec/fbtu/users/rm_spec.rb +56 -19
- data/spec/spec_helper.rb +21 -5
- data/test/real-add-rm-user-test.sh +112 -0
- metadata +103 -118
- data/spec/fbtu/apps/add_spec.rb +0 -36
- data/spec/fbtu/users/add_spec.rb +0 -22
|
@@ -3,20 +3,32 @@ require 'uri'
|
|
|
3
3
|
module FacebookTestUsers
|
|
4
4
|
class User
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
attr_accessor :id, :access_token, :login_url, :email, :password
|
|
7
7
|
|
|
8
8
|
def initialize(attrs)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@id, @access_token, @login_url = %w[id access_token login_url].map do |field|
|
|
12
|
-
attrs[field.to_s] || attrs[field.to_sym]
|
|
9
|
+
attrs.each do |field, value|
|
|
10
|
+
instance_variable_set("@#{field}", value) if respond_to?(field)
|
|
13
11
|
end
|
|
14
12
|
end
|
|
15
13
|
|
|
14
|
+
def change(options = {})
|
|
15
|
+
RestClient.post(change_url, {:access_token => access_token}.merge(options))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def owner_apps(app)
|
|
19
|
+
RestClient.get(owner_apps_url(app.access_token))
|
|
20
|
+
end
|
|
21
|
+
|
|
16
22
|
def destroy
|
|
17
23
|
RestClient.delete(destroy_url)
|
|
18
24
|
end
|
|
19
25
|
|
|
26
|
+
# Facebook test users all share the same birthday. Perhaps it's the
|
|
27
|
+
# developer's!
|
|
28
|
+
def birthday
|
|
29
|
+
Date.new(1980, 8, 8)
|
|
30
|
+
end
|
|
31
|
+
|
|
20
32
|
def send_friend_request_to(other)
|
|
21
33
|
RestClient.post(friend_request_url_for(other),
|
|
22
34
|
'access_token' => access_token.to_s)
|
|
@@ -24,10 +36,18 @@ module FacebookTestUsers
|
|
|
24
36
|
|
|
25
37
|
private
|
|
26
38
|
|
|
39
|
+
def change_url
|
|
40
|
+
GRAPH_API_BASE + "/#{id}"
|
|
41
|
+
end
|
|
42
|
+
|
|
27
43
|
def destroy_url
|
|
28
44
|
GRAPH_API_BASE + "/#{id}?access_token=#{URI.escape(access_token.to_s)}"
|
|
29
45
|
end
|
|
30
46
|
|
|
47
|
+
def owner_apps_url(token)
|
|
48
|
+
GRAPH_API_BASE + "/#{id}/ownerapps?access_token=#{URI.escape(token.to_s)}"
|
|
49
|
+
end
|
|
50
|
+
|
|
31
51
|
def friend_request_url_for(other)
|
|
32
52
|
GRAPH_API_BASE + "/#{id}/friends/#{other.id}"
|
|
33
53
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu apps add-user" do
|
|
4
|
+
context "with both apps installed and a user created" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@alpha = register_app('alpha')
|
|
7
|
+
beta = register_app('beta')
|
|
8
|
+
@alice = create_user_for(@alpha)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "adds the user to another app" do
|
|
12
|
+
fbtu %w[apps add-user --from-app alpha --to-app beta --user] + [@alice.id]
|
|
13
|
+
@out.should include("User #{@alice.id} added to app 'beta'")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "adds the user to another app without read_stream permissions" do
|
|
17
|
+
fbtu %w[apps add-user --from-app alpha --to-app beta
|
|
18
|
+
--permissions none --user] + [@alice.id]
|
|
19
|
+
@out.should include("User #{@alice.id} added to app 'beta'")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "adds the user to another app without installing the app" do
|
|
23
|
+
fbtu %w[apps add-user --from-app alpha --to-app beta
|
|
24
|
+
--installed false --user] + [@alice.id]
|
|
25
|
+
@out.should include("User #{@alice.id} added to app 'beta'")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it "doesn't add the user from an app it's not associated to" do
|
|
29
|
+
error = "Facebook refused for some other reason."
|
|
30
|
+
fakeweb_register_bad_request(:post,
|
|
31
|
+
"https://graph.facebook.com/#{@alpha.id}/accounts/test-users",
|
|
32
|
+
9999, error)
|
|
33
|
+
lambda do
|
|
34
|
+
fbtu %w[apps add-user --from-app beta --to-app alpha --user] + [@alice.id], \
|
|
35
|
+
:quiet => true
|
|
36
|
+
end.should raise_error
|
|
37
|
+
@err.should include(error)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
context "with only one app installed and a user created" do
|
|
42
|
+
before(:each) do
|
|
43
|
+
alpha = register_app('alpha')
|
|
44
|
+
@alice = create_user_for(alpha)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "tells you if there was no such app to add the user to" do
|
|
48
|
+
lambda do
|
|
49
|
+
fbtu %w[apps add-user --from-app alpha --to-app beta --user] + [@alice.id], :quiet => true
|
|
50
|
+
end.should raise_error
|
|
51
|
+
@err.should include("Unknown app beta")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "tells you if there was no such app to add the user from" do
|
|
55
|
+
lambda do
|
|
56
|
+
fbtu %w[apps add-user --from-app beta --to-app alpha --user] + [@alice.id], :quiet => true
|
|
57
|
+
end.should raise_error
|
|
58
|
+
@err.should include("Unknown app beta")
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu apps register" do
|
|
4
|
+
it "lets you create an app" do
|
|
5
|
+
fbtu %w[apps register --app-id 123456 --app-secret 7890 --name hydrogen]
|
|
6
|
+
|
|
7
|
+
fbtu %w[apps list]
|
|
8
|
+
@out.should include("hydrogen")
|
|
9
|
+
@out.should_not include("squirrel")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "won't let you create an app with a bogus ID" do
|
|
13
|
+
lambda do
|
|
14
|
+
fbtu %w[apps register --app-id xyzzy --app-secret 7890 --name hydrogen], :quiet => true
|
|
15
|
+
end.should raise_error
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "won't let you create an app with a bogus secret" do
|
|
19
|
+
lambda do
|
|
20
|
+
fbtu %w[apps register --app-id 123456 --app-secret xyzzy --name hydrogen], :quiet => true
|
|
21
|
+
end.should raise_error
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "won't let you create an app without a name" do
|
|
25
|
+
lambda do
|
|
26
|
+
fbtu %w[apps register --app-id 123456 --app-secret 123456], :quiet => true
|
|
27
|
+
end.should raise_error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "won't let you create an app with a duplicate name" do
|
|
31
|
+
fbtu %w[apps register --app-id 123456 --app-secret 7890 --name hydrogen]
|
|
32
|
+
lambda do
|
|
33
|
+
fbtu %w[apps register --app-id 123456 --app-secret 7890 --name hydrogen], :quiet => true
|
|
34
|
+
end.should raise_error
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu apps rm-user" do
|
|
4
|
+
context "with both apps installed and a user created" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@alpha = register_app('alpha')
|
|
7
|
+
@beta = register_app('beta')
|
|
8
|
+
@alice = create_user_for(@alpha)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "removes the user from another app" do
|
|
12
|
+
delete_url = "https://graph.facebook.com/#{@alpha.id}/accounts/test-users?uid=#{@alice.id}&access_token=#{@alpha.access_token}"
|
|
13
|
+
FakeWeb.register_uri(:delete, delete_url, :body => "true")
|
|
14
|
+
fbtu %w[apps rm-user --app alpha --user] + [@alice.id]
|
|
15
|
+
@out.should include("User #{@alice.id} removed from app 'alpha'")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "does not removes the user from an app it's not associated with" do
|
|
19
|
+
delete_url = "https://graph.facebook.com/#{@beta.id}/accounts/test-users?uid=#{@alice.id}&access_token=#{@beta.access_token}"
|
|
20
|
+
error = "This is not a valid test user for this app"
|
|
21
|
+
fakeweb_register_bad_request(:delete, delete_url, 2901, error)
|
|
22
|
+
lambda do
|
|
23
|
+
fbtu %w[apps rm-user --app beta --user] + [@alice.id], :quiet => true
|
|
24
|
+
end.should raise_error
|
|
25
|
+
@err.should include(error)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
context "with only one app installed and a user created" do
|
|
30
|
+
before(:each) do
|
|
31
|
+
alpha = register_app('alpha')
|
|
32
|
+
@alice = create_user_for(alpha)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "tells you if there was no such app to remove the user from" do
|
|
36
|
+
lambda do
|
|
37
|
+
fbtu %w[apps rm-user --app beta --user] + [@alice.id], :quiet => true
|
|
38
|
+
end.should raise_error
|
|
39
|
+
@err.should include("Unknown app beta")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/spec/fbtu/apps_spec.rb
CHANGED
|
@@ -8,7 +8,9 @@ describe "fbtu apps" do
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
it "defaults to listing apps" do
|
|
11
|
-
|
|
11
|
+
pending "thor issue with default_task in subcommands " \
|
|
12
|
+
"(https://github.com/wycats/thor/issues/306)"
|
|
13
|
+
fbtu %w[apps register --name shlomo --app-id 12345 --app-secret abcdef]
|
|
12
14
|
fbtu %w[apps]
|
|
13
15
|
@out.should include("shlomo")
|
|
14
16
|
@out.should include("12345")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu users change" do
|
|
4
|
+
before(:each) do
|
|
5
|
+
alpha = register_app('alpha')
|
|
6
|
+
|
|
7
|
+
@alice = create_user_for(alpha)
|
|
8
|
+
@bob = create_user_for(alpha)
|
|
9
|
+
|
|
10
|
+
FakeWeb.register_uri(:post,
|
|
11
|
+
"https://graph.facebook.com/#{@alice.id}",
|
|
12
|
+
:body => 'true')
|
|
13
|
+
|
|
14
|
+
FakeWeb.register_uri(:post,
|
|
15
|
+
"https://graph.facebook.com/#{@bob.id}",
|
|
16
|
+
:body => 'false')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "changes an existing user's name" do
|
|
20
|
+
fbtu %w[users change --app alpha --user] + [@alice.id] + %w[--name Alice]
|
|
21
|
+
@out.should include("Successfully changed user")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "changes an existing user's password" do
|
|
25
|
+
fbtu %w[users change --app alpha --user] + [@alice.id] + %w[--password topsecret]
|
|
26
|
+
@out.should include("Successfully changed user")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "changes an existing user's user and password" do
|
|
30
|
+
fbtu %w[users change --app alpha --user] + [@alice.id] +
|
|
31
|
+
%w[--name Alice --password topsecret]
|
|
32
|
+
@out.should include("Successfully changed user")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "fails to change an existing user's name" do
|
|
36
|
+
fbtu %w[users change --app alpha --user] + [@bob.id] + %w[--name Bob]
|
|
37
|
+
@out.should include("Failed to change user")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "tells you if there was no such user" do
|
|
41
|
+
lambda do
|
|
42
|
+
fbtu %w[users change --app alpha --user bogus], :quiet => true
|
|
43
|
+
end.should raise_error
|
|
44
|
+
@err.should include("Unknown user")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu users create" do
|
|
4
|
+
context "with the app installed" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
alpha = register_app('alpha')
|
|
7
|
+
|
|
8
|
+
@new_user_id = 60189
|
|
9
|
+
new_user_response = {
|
|
10
|
+
"id" => @new_user_id,
|
|
11
|
+
"access_token" => 5795927166794,
|
|
12
|
+
"login_url" => "https://facebook.example.com/login/#@new_user_id",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
FakeWeb.register_uri(:post,
|
|
16
|
+
"https://graph.facebook.com/#{alpha.id}/accounts/test-users",
|
|
17
|
+
:body => new_user_response.to_json)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "creates a user" do
|
|
21
|
+
fbtu %w[users create --app alpha]
|
|
22
|
+
@out.should include(@new_user_id.to_s)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "creates a user with the app not installed" do
|
|
26
|
+
# The API doesn't return the installed status
|
|
27
|
+
fbtu %w[users create --app alpha --installed false]
|
|
28
|
+
@out.should include(@new_user_id.to_s)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it "creates a named user" do
|
|
32
|
+
fbtu %w[users create --app alpha --name Joe]
|
|
33
|
+
# The API doesn't return the name
|
|
34
|
+
@out.should include(@new_user_id.to_s)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "creates a user with a locale" do
|
|
38
|
+
fbtu %w[users create --app alpha --locale en_GB]
|
|
39
|
+
# The API doesn't return the locale
|
|
40
|
+
@out.should include(@new_user_id.to_s)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "tells you if there was no such app" do
|
|
45
|
+
lambda do
|
|
46
|
+
fbtu %w[users create --app beta], :quiet => true
|
|
47
|
+
end.should raise_error
|
|
48
|
+
@err.should include("Unknown app beta")
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -2,10 +2,10 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_hel
|
|
|
2
2
|
|
|
3
3
|
describe "fbtu users friend" do
|
|
4
4
|
before(:each) do
|
|
5
|
-
alpha =
|
|
5
|
+
alpha = register_app('alpha')
|
|
6
6
|
|
|
7
|
-
@alice =
|
|
8
|
-
@bob =
|
|
7
|
+
@alice = create_user_for(alpha)
|
|
8
|
+
@bob = create_user_for(alpha)
|
|
9
9
|
|
|
10
10
|
FakeWeb.register_uri(:post,
|
|
11
11
|
"https://graph.facebook.com/#{@alice.id}/friends/#{@bob.id}",
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))
|
|
2
|
+
|
|
3
|
+
describe "fbtu users list-apps" do
|
|
4
|
+
context "with two apps installed and a user created" do
|
|
5
|
+
before(:each) do
|
|
6
|
+
@alpha = register_app('alpha')
|
|
7
|
+
@beta = register_app('beta')
|
|
8
|
+
@alice = create_user_for(@alpha)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "lists the apps" do
|
|
12
|
+
list_url = "https://graph.facebook.com/#{@alice.id}/ownerapps?access_token=#{@alpha.access_token}"
|
|
13
|
+
response = {
|
|
14
|
+
"data" => [
|
|
15
|
+
{"name" => @alpha.name, "id" => @alpha.id },
|
|
16
|
+
{"name" => @beta.name, "id" => @beta.id },
|
|
17
|
+
],
|
|
18
|
+
"paging" => {
|
|
19
|
+
"next" => "https => \\/\\/graph.facebook.com\\/#{@alice.id}\\/ownerapps?access_token=#{@alpha.access_token}&limit=5000&offset=5000&__after_id=137431703386"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
FakeWeb.register_uri(:get, list_url, :body => response.to_json)
|
|
23
|
+
|
|
24
|
+
fbtu %w[users list-apps --app alpha --user] + [@alice.id]
|
|
25
|
+
@out.should include(@alpha.name)
|
|
26
|
+
@out.should include(@beta.name)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
context "with only one app installed and no user" do
|
|
31
|
+
before(:each) do
|
|
32
|
+
alpha = register_app('alpha')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
it "tells you if there was no such user to list apps for" do
|
|
36
|
+
lambda do
|
|
37
|
+
fbtu %w[users list-apps --app alpha --user 12345], :quiet => true
|
|
38
|
+
end.should raise_error
|
|
39
|
+
@err.should include("Unknown user '12345'")
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "with a user and one apps" do
|
|
44
|
+
before(:each) do
|
|
45
|
+
alpha = register_app('alpha')
|
|
46
|
+
@alice = create_user_for(alpha)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "tells you if there was no such app owning the user" do
|
|
50
|
+
lambda do
|
|
51
|
+
fbtu %w[users list-apps --app beta --user] + [@alice.id], :quiet => true
|
|
52
|
+
end.should raise_error
|
|
53
|
+
@err.should include("Unknown app beta")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_hel
|
|
|
2
2
|
|
|
3
3
|
describe "fbtu users list" do
|
|
4
4
|
before(:each) do
|
|
5
|
-
fbtu %w[apps
|
|
5
|
+
fbtu %w[apps register --name alpha --app-id 123456 --app-secret abcdef]
|
|
6
6
|
FakeWeb.register_uri(:get,
|
|
7
7
|
'https://graph.facebook.com/oauth/access_token?client_id=123456&client_secret=abcdef&grant_type=client_credentials',
|
|
8
8
|
:body => 'access_token=doublesecret')
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_hel
|
|
|
2
2
|
|
|
3
3
|
describe "fbtu users nuke" do
|
|
4
4
|
before(:each) do
|
|
5
|
-
fbtu %w[apps
|
|
5
|
+
fbtu %w[apps register --name alpha --app-id 123456 --app-secret abcdef]
|
|
6
6
|
FakeWeb.register_uri(:get,
|
|
7
7
|
'https://graph.facebook.com/oauth/access_token?client_id=123456&client_secret=abcdef&grant_type=client_credentials',
|
|
8
8
|
:body => 'access_token=doublesecret')
|
data/spec/fbtu/users/rm_spec.rb
CHANGED
|
@@ -2,36 +2,73 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_hel
|
|
|
2
2
|
|
|
3
3
|
describe "fbtu users rm" do
|
|
4
4
|
before(:each) do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
@alpha = register_app('alpha')
|
|
6
|
+
@alice = create_user_for(@alpha)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "deletes the user" do
|
|
10
|
+
delete_url = "https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}"
|
|
11
|
+
FakeWeb.register_uri(:delete, delete_url, :body => "true")
|
|
12
|
+
|
|
13
|
+
fbtu %w[users rm --app alpha --user] + [@alice.id]
|
|
14
|
+
|
|
15
|
+
FakeWeb.should have_requested(:delete,
|
|
16
|
+
"https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}")
|
|
17
|
+
@out.should include("User ID #{@alice.id} removed")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "doesn't delete the user if it's associated with another app" do
|
|
21
|
+
delete_url = "https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}"
|
|
22
|
+
error = "(#2903) Cannot delete this test account because it is associated with other applications."
|
|
23
|
+
response = {
|
|
24
|
+
"error" => {
|
|
25
|
+
"message" => error,
|
|
26
|
+
"type" => "OAuthException",
|
|
27
|
+
"code" => 2903
|
|
28
|
+
}
|
|
14
29
|
}
|
|
15
30
|
|
|
16
|
-
FakeWeb.register_uri(:
|
|
17
|
-
|
|
18
|
-
|
|
31
|
+
FakeWeb.register_uri(:delete, delete_url, :status => [ '400', 'Bad Request' ],
|
|
32
|
+
:body => response.to_json)
|
|
33
|
+
|
|
34
|
+
lambda do
|
|
35
|
+
fbtu %w[users rm --app alpha --user] + [@alice.id], :quiet => true
|
|
36
|
+
end.should raise_error
|
|
37
|
+
|
|
38
|
+
FakeWeb.should have_requested(:delete,
|
|
39
|
+
"https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}")
|
|
40
|
+
@err.should include(error)
|
|
41
|
+
@err.should include("fbtu users list-apps")
|
|
42
|
+
@err.should include("fbtu apps rm-user")
|
|
43
|
+
@err.should include("Then re-run this command.")
|
|
19
44
|
end
|
|
20
45
|
|
|
21
|
-
it "
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
46
|
+
it "doesn't delete the user if there's another issue" do
|
|
47
|
+
delete_url = "https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}"
|
|
48
|
+
error = "(#9999) Facebook refused for some other reason."
|
|
49
|
+
response = {
|
|
50
|
+
"error" => {
|
|
51
|
+
"message" => error,
|
|
52
|
+
"type" => "OAuthException",
|
|
53
|
+
"code" => 9999
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
FakeWeb.register_uri(:delete, delete_url, :status => [ '400', 'Bad Request' ],
|
|
58
|
+
:body => response.to_json)
|
|
25
59
|
|
|
26
|
-
|
|
60
|
+
lambda do
|
|
61
|
+
fbtu %w[users rm --app alpha --user] + [@alice.id], :quiet => true
|
|
62
|
+
end.should raise_error
|
|
27
63
|
|
|
28
64
|
FakeWeb.should have_requested(:delete,
|
|
29
|
-
"https://graph.facebook.com
|
|
65
|
+
"https://graph.facebook.com/#{@alice.id}?access_token=#{@alice.access_token}")
|
|
66
|
+
@err.should include(error)
|
|
30
67
|
end
|
|
31
68
|
|
|
32
69
|
it "tells you if there was no such user" do
|
|
33
70
|
lambda do
|
|
34
|
-
fbtu %w[users rm --app alpha
|
|
71
|
+
fbtu %w[users rm --app alpha --user bogus], :quiet => true
|
|
35
72
|
end.should raise_error
|
|
36
73
|
@err.should include("Unknown user")
|
|
37
74
|
end
|