<commit_before># Responses by MockHTTPService are taken directly from 
# this file.
# 
# Structure
# ----------
#
# path:
#   arguments:    # sorted by key
#     method:     # HTTP method (GET, POST, DELETE, etc.)
#       with_token:
#       no_token:

# ====== REST API ===== 
rest_api:

# -- Stubbed Responses --
  /method/fql.query:
    query=select first_name from user where uid = 2901279:
      get: 
        no_token: '[{"first_name":"Luke"}]'
        with_token: '[{"first_name":"Luke"}]'
    query=select read_stream from permissions where uid = 2901279:
      get:
        with_token: '[{"read_stream":1}]' 
        no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 2901279"}]}'

  /method/fql.multiquery:
    'queries=<%= MultiJson.encode({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>':
      get: 
        with_token: '[{"name":"query1", "fql_result_set":[]},{"name":"query2", "fql_result_set":[]},{"name":"query3", "fql_result_set":[]}]'
        no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 2901279"}]}'
    'queries=<%= MultiJson.encode({"query1" => "select first_name from user where uid = 2901279", "query2" => "select first_name from user where uid = 2905623"}) %>':
      get:
        with_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]' 
        no_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]'




# ====== GRAPH API =====
graph_api:

# -- Common Responses --

  # Error responses for when a token is required, but not given
  token_required_responses: &token_required
    no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
  
  # Common mock item responses
  item_deleted: &item_deleted
    delete:
      with_token: 'true'

  # OAuth error response
  oauth_error: &oauth_error
    no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'

  # Subscription error response
  verification_error: &verification_error
    with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
    
  test_user_no_perms: &test_user_no_perms
    post:
      with_token: '{"id": "7<PASSWORD>", "access_token":"<%= APP_ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
  
  test_user_befriended: &test_user_befriended
    post:
      with_token: 'true'
  
# -- Stubbed Responses --
  root:
    ids=contextoptional,koppel: 
      get:
        with_token: '{"contextoptional":"{}","koppel":"{}"}'
        no_token: '{"contextoptional":"{}","koppel":"{}"}'

    # Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here 
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"id\":\"456\"}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/picture"}]) %>:
      post:
        with_token: '[{"headers":[{"name":"Location","value":"http://google.com"}]}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[]}"}]'
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[]}"}]'
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"body":"{\"id\":\"123\"}"}]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
      post:
        with_token: '[{"body": "{\"id\": \"MOCK_LIKE\"}"},{"body":true}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
      post:
        with_token: '[null,{"body":"{}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
      post:
        with_token: '[{"body":"{\"data\":[]}"},{"body":"{}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>:
      post:
        with_token: '{"error":190,"error_description":"Error validating access token."}'
    batch=<%= MultiJson.encode([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
      post:
        with_token: '[{"body":"[{\"first_name\":\"Alex\"}]"}]'

    # dependencies
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>:
      post: &batch_dependent
        with_token: '[null,{"body":"{\"id\":\"123\"}"}]'  
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'

    # attached files tests
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
      post:
        with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
      post:
        with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}, {"body":"{\"id\": \"MOCK_PHOTO\"}"}]'




  /me:
    no_args:
      get:
        <<: *token_required
        with_token: '{"updated_time": 1}'
    fields=id:
      get: 
        with_token: '{"id": "2901279"}'

  /me/feed:
    message=Hello, world, from the test suite!: 
      post:
        with_token: '{"id": "MOCK_FEED_ITEM"}'
    message=Hello, world, from the test suite, testing comments!:
      post:
        with_token: '{"id": "MOCK_FEED_ITEM"}'
    message=the cats are asleep: 
      post:
        with_token: '{"id": "FEED_ITEM_CATS"}'
    message=Hello, world, from the test suite delete method!: 
      post:
        with_token: '{"id": "FEED_ITEM_DELETE"}'
    message=Hello, world, from the test suite batch API!: 
      post:
        with_token: '{"id": "FEED_ITEM_BATCH"}'
    link=http://oauth.twoalex.com/&message=Hello, world, from the test suite again!&name=OAuth Playground:
      post:
        with_token: '{"id": "FEED_ITEM_CONTEXT"}'

  /me/photos:
    source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    message=This is the test message&source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    url=https://github.com/arsduo/koala/raw/master/spec/fixtures/beach.jpg:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO_FROM_URL"}'
    message=my message&url=https://github.com/arsduo/koala/raw/master/spec/fixtures/beach.jpg:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO_FROM_URL"}'

  /me/videos:
    source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    message=This is the test message&source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'

  /koppel:
    no_args:
      get:
        with_token: '{"id": 1, "name": 1, "updated_time": 1}'
        no_token: '{"id": 1, "name": 1}'
                
  /contextoptional:
    no_args:
      get:
        with_token: '{"id": 1, "name": 1}'
        no_token: '{"id": 1, "name": 1}'
        
  /contextoptional/photos: 
    no_args: 
      get: 
        with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
    
  /lukeshepard/friends: 
    no_args: 
      get: 
        <<: *token_required
        with_token: '{"data": [{}]}'
  
  /lukeshepard/picture:
    type=large:
      get:
        no_token:
          code: 302
          headers:
            Location: https://facebook.com/large
        with_token:
          code: 302
          headers:
            Location: https://facebook.com/large
    
   
  /chris.baclig/picture:
    no_args:
      get:
        no_token:
          code: 302
          headers:
            Location: http://facebook.com/
        with_token:
          code: 302
          headers:
            Location: http://facebook.com/

  /comments:
    ids=http://developers.facebook.com/blog/post/472:
      get: 
        with_token: '{"http://developers.facebook.com/blog/post/472": []}'
        no_token: '{"http://developers.facebook.com/blog/post/472": []}'
    ids=http://developers.facebook.com/blog/post/490,http://developers.facebook.com/blog/post/472:
      get: 
        with_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}'
        no_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}'
    ids=:
      get:
        body: '{"error": {"type": "OAuthException","message": "Cannot specify an empty identifier"}}'
        code: 400
    no_args:
      get:
        body: '{"error": {"type": "Exception","message": "No node specified"}}'
        code: 500        

  /search:
    q=facebook:
      get: 
        with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
    "limit=25&q=facebook&until=2010-09-23T21:17:33+0000":
      get: 
        with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
      
  '/115349521819193_113815981982767':
    no_args:
      delete:
        <<: *token_required
  
  # -- OAuth responses --
  /oauth/access_token: 
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
      get:
        no_token: access_token=<%= ACCESS_TOKEN %>
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>: 
      get: 
        <<: *oauth_error
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
      post:
        no_token: access_token=<%= APP_ACCESS_TOKEN %>
  /oauth/exchange_sessions:
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred: 
      post:
        no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= [OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]].join(",") %>&type=client_cred: 
      post:
        no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= ["foo"].concat([OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]]).join(",") %>&type=client_cred: 
      post:
        no_token: '[null, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo,bar&type=client_cred: 
      post:
        no_token: '[null, null]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo&type=client_cred: 
      post:
        no_token: '[null]'



# -- Subscription Responses -- 
  /<%= APP_ID %>/subscriptions:
    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token:
          code: 200
    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
    callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
    object=user:
      delete:
        with_token:
          code: 200
    object=kittens:
      delete:
        with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
    no_args:
      delete: 
        with_token:
          code: 200
      get:
        with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'


    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
      get:
        with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'

# -- Mock Item Responses --

  /MOCK_FEED_ITEM/likes:
    no_args:
      post:
        with_token: '{"id": "MOCK_LIKE"}'
        
  /MOCK_FEED_ITEM/comments:
    message=it's my comment!:
      post:
        with_token: '{"id": "MOCK_COMMENT"}'
  
  /MOCK_FEED_ITEM:
    no_args:
      <<: *item_deleted
  
  /FEED_ITEM_CONTEXT:
    no_args: 
      <<: *item_deleted
      get:
        with_token: '{"link":"http://oauth.twoalex.com/", "name": "OAuth Playground"}'
  
  /FEED_ITEM_CATS:
    no_args:
      <<: *item_deleted
      get: 
        with_token: '{"message": "the cats are asleep"}'
  
  /FEED_ITEM_DELETE:
    no_args:
      <<: *item_deleted

  /FEED_ITEM_DELETE/likes:
    no_args:
      <<: *item_deleted
      post: 
        with_token: 'true'
            
  /MOCK_COMMENT:
    no_args:
      <<: *item_deleted
      get:
        with_token: "{\"message\": \"it's my comment!\"}"
  /MOCK_PHOTO:
    no_args:
      <<: *item_deleted
      get:
        with_token: "{\"name\": \"This is the test message\"}"
        
# -- Mock Test User Responses --
  /<%= APP_ID %>/accounts/test-users:
    installed=false:
      <<: *test_user_no_perms
    installed=false&permissions=read_stream:
      <<: *test_user_no_perms                                                                                                                                                            
    installed=true&permissions=read_stream:
      post:
        with_token: '{"id": "9<PASSWORD>", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
    installed=true&permissions=read_stream,user_interests:
      post:
        with_token: '{"id": "8<PASSWORD>", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
    no_args:
      get:
        with_token: '{"data":[{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}, {"id": "888888888", "access_token":"<KEY> "login_url":"https://www.facebook.com/platform/test_account.."}]}'
        
  /999999999:
    no_args:
      <<: *item_deleted

  /999999999/friends/888888888:
    no_args:
      post:
        with_token: 'true'


  /9999999991:
    no_args:
      delete:
        with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
 
  /888888888:
    no_args:
      <<: *item_deleted   

  /888888888/friends/999999999:
    no_args:
      <<: *test_user_befriended


  /777777777:
    no_args:
      <<: *item_deleted
<commit_msg>Changed the image URL being used for put_picture tests.<commit_after># Responses by MockHTTPService are taken directly from 
# this file.
# 
# Structure
# ----------
#
# path:
#   arguments:    # sorted by key
#     method:     # HTTP method (GET, POST, DELETE, etc.)
#       with_token:
#       no_token:

# ====== REST API ===== 
rest_api:

# -- Stubbed Responses --
  /method/fql.query:
    query=select first_name from user where uid = 2901279:
      get: 
        no_token: '[{"first_name":"Luke"}]'
        with_token: '[{"first_name":"Luke"}]'
    query=select read_stream from permissions where uid = 2901279:
      get:
        with_token: '[{"read_stream":1}]' 
        no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 2901279"}]}'

  /method/fql.multiquery:
    'queries=<%= MultiJson.encode({"query1" => "select post_id from stream where source_id = me()", "query2" => "select fromid from comment where post_id in (select post_id from #query1)", "query3" => "select uid, name from user where uid in (select fromid from #query2)"}) %>':
      get: 
        with_token: '[{"name":"query1", "fql_result_set":[]},{"name":"query2", "fql_result_set":[]},{"name":"query3", "fql_result_set":[]}]'
        no_token: '{"error_code":104,"error_msg":"Requires valid signature","request_args":[{"key":"method","value":"fql.query"},{"key":"format","value":"json"},{"key":"query","value":"select read_stream from permissions where uid = 2901279"}]}'
    'queries=<%= MultiJson.encode({"query1" => "select first_name from user where uid = 2901279", "query2" => "select first_name from user where uid = 2905623"}) %>':
      get:
        with_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]' 
        no_token: '[{"name":"query1", "fql_result_set":[{"first_name":"Luke"}]},{"name":"query2", "fql_result_set":[{"first_name":"Alex"}]}]'




# ====== GRAPH API =====
graph_api:

# -- Common Responses --

  # Error responses for when a token is required, but not given
  token_required_responses: &token_required
    no_token: '{"error":{"type":"OAuthAccessTokenException", "message":"An access token is required to request this resource."}}'
  
  # Common mock item responses
  item_deleted: &item_deleted
    delete:
      with_token: 'true'

  # OAuth error response
  oauth_error: &oauth_error
    no_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'

  # Subscription error response
  verification_error: &verification_error
    with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
    
  test_user_no_perms: &test_user_no_perms
    post:
      with_token: '{"id": "<PASSWORD>", "access_token":"<%= APP_ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
  
  test_user_befriended: &test_user_befriended
    post:
      with_token: 'true'
  
# -- Stubbed Responses --
  root:
    ids=contextoptional,koppel: 
      get:
        with_token: '{"contextoptional":"{}","koppel":"{}"}'
        no_token: '{"contextoptional":"{}","koppel":"{}"}'

    # Ruby 1.8.7 and 1.9.2 generate JSON with different key ordering, hence we have to dynamically generate it here 
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "koppel"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"id\":\"456\"}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/picture"}]) %>:
      post:
        with_token: '[{"headers":[{"name":"Location","value":"http://google.com"}]}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me"},{"method" => "get", "relative_url" => "me/friends"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[]}"}]'
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me"}, {"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
      post:
        with_token: '[{"body":"{\"id\":\"123\"}"}, {"body":"{\"data\":[]}"}]'
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights"}, {"method"=>"get", "relative_url"=>"koppel?access_token=#{CGI.escape APP_ACCESS_TOKEN}"}]) %>:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},{"body":"{\"id\":\"123\"}"}]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"FEED_ITEM_BATCH/likes"}, {"method"=>"delete", "relative_url"=> "FEED_ITEM_BATCH"}]) %>:
      post:
        with_token: '[{"body": "{\"id\": \"MOCK_LIKE\"}"},{"body":true}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
      post:
        with_token: '[null,{"body":"{}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5", "name" => "get-friends", "omit_response_on_success" => false}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=get-friends:$.data.*.id}"}"}]) %>:
      post:
        with_token: '[{"body":"{\"data\":[]}"},{"body":"{}"}]'
    batch=<%= MultiJson.encode([{"method" => "get", "relative_url" => "me/friends?limit=5"}, {"method" => "get", "relative_url" => "?ids=#{CGI.escape "{result=i-dont-exist:$.data.*.id}"}"}]) %>:
      post:
        with_token: '{"error":190,"error_description":"Error validating access token."}'
    batch=<%= MultiJson.encode([{"method" => "post", "relative_url" => "method/fql.query", "body" => "query=select+first_name+from+user+where+uid%3D2905623"}]) %>:
      post:
        with_token: '[{"body":"[{\"first_name\":\"Alex\"}]"}]'

    # dependencies
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"me", "name" => "getme"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getme"}]) %>:
      post: &batch_dependent
        with_token: '[null,{"body":"{\"id\":\"123\"}"}]'  
    batch=<%= MultiJson.encode([{"method"=>"get", "relative_url"=>"#{OAUTH_DATA["app_id"]}/insights", "name" => "getdata"}, {"method"=>"get", "relative_url"=>"koppel", "depends_on" => "getdata"}]) %>:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'

    # attached files tests
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
      post:
        with_token: '[{"body": "{\"error\":{\"type\":\"AnError\", \"message\":\"An error occurred!.\"}}"},null]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}]) %>&op1_file0=[FILE]:
      post:
        with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}]'
    batch=<%= MultiJson.encode([{"method"=>"post", "relative_url"=>"me/photos", "attached_files" => "op1_file0"}, {"method"=>"post", "relative_url"=>"koppel/photos", "attached_files" => "op2_file0"}]) %>&op1_file0=[FILE]&op2_file0=[FILE]:
      post:
        with_token: '[{"body":"{\"id\": \"MOCK_PHOTO\"}"}, {"body":"{\"id\": \"MOCK_PHOTO\"}"}]'




  /me:
    no_args:
      get:
        <<: *token_required
        with_token: '{"updated_time": 1}'
    fields=id:
      get: 
        with_token: '{"id": "2901279"}'

  /me/feed:
    message=Hello, world, from the test suite!: 
      post:
        with_token: '{"id": "MOCK_FEED_ITEM"}'
    message=Hello, world, from the test suite, testing comments!:
      post:
        with_token: '{"id": "MOCK_FEED_ITEM"}'
    message=the cats are asleep: 
      post:
        with_token: '{"id": "FEED_ITEM_CATS"}'
    message=Hello, world, from the test suite delete method!: 
      post:
        with_token: '{"id": "FEED_ITEM_DELETE"}'
    message=Hello, world, from the test suite batch API!: 
      post:
        with_token: '{"id": "FEED_ITEM_BATCH"}'
    link=http://oauth.twoalex.com/&message=Hello, world, from the test suite again!&name=OAuth Playground:
      post:
        with_token: '{"id": "FEED_ITEM_CONTEXT"}'

  /me/photos:
    source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    message=This is the test message&source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    url=http://img.slate.com/images/redesign2008/slate_logo.gif:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO_FROM_URL"}'
    message=my message&url=http://img.slate.com/images/redesign2008/slate_logo.gif:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO_FROM_URL"}'

  /me/videos:
    source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'
    message=This is the test message&source=[FILE]:
      post:
        <<: *token_required
        with_token: '{"id": "MOCK_PHOTO"}'

  /koppel:
    no_args:
      get:
        with_token: '{"id": 1, "name": 1, "updated_time": 1}'
        no_token: '{"id": 1, "name": 1}'
                
  /contextoptional:
    no_args:
      get:
        with_token: '{"id": 1, "name": 1}'
        no_token: '{"id": 1, "name": 1}'
        
  /contextoptional/photos: 
    no_args: 
      get: 
        with_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
    
  /lukeshepard/friends: 
    no_args: 
      get: 
        <<: *token_required
        with_token: '{"data": [{}]}'
  
  /lukeshepard/picture:
    type=large:
      get:
        no_token:
          code: 302
          headers:
            Location: https://facebook.com/large
        with_token:
          code: 302
          headers:
            Location: https://facebook.com/large
    
   
  /chris.baclig/picture:
    no_args:
      get:
        no_token:
          code: 302
          headers:
            Location: http://facebook.com/
        with_token:
          code: 302
          headers:
            Location: http://facebook.com/

  /comments:
    ids=http://developers.facebook.com/blog/post/472:
      get: 
        with_token: '{"http://developers.facebook.com/blog/post/472": []}'
        no_token: '{"http://developers.facebook.com/blog/post/472": []}'
    ids=http://developers.facebook.com/blog/post/490,http://developers.facebook.com/blog/post/472:
      get: 
        with_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}'
        no_token: '{"http://developers.facebook.com/blog/post/490": [], "http://developers.facebook.com/blog/post/472": []}'
    ids=:
      get:
        body: '{"error": {"type": "OAuthException","message": "Cannot specify an empty identifier"}}'
        code: 400
    no_args:
      get:
        body: '{"error": {"type": "Exception","message": "No node specified"}}'
        code: 500        

  /search:
    q=facebook:
      get: 
        with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
    "limit=25&q=facebook&until=2010-09-23T21:17:33+0000":
      get: 
        with_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
        no_token: '{"data": [{"id": "507731521_100412693339488"}], "paging": {"previous": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000", "next": "https:\/\/graph.facebook.com\/7204941866\/photos?limit=25&until=2008-09-15T18%3A30%3A25%2B0000"}}'
      
  '/115349521819193_113815981982767':
    no_args:
      delete:
        <<: *token_required
  
  # -- OAuth responses --
  /oauth/access_token: 
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=<%= OAUTH_CODE %>&redirect_uri=<%= OAUTH_DATA["callback_url"] %>:
      get:
        no_token: access_token=<%= ACCESS_TOKEN %>
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&code=foo&redirect_uri=<%= OAUTH_DATA["callback_url"] %>: 
      get: 
        <<: *oauth_error
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&type=client_cred:
      post:
        no_token: access_token=<%= APP_ACCESS_TOKEN %>
  /oauth/exchange_sessions:
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= OAUTH_DATA["session_key"] %>&type=client_cred: 
      post:
        no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= [OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]].join(",") %>&type=client_cred: 
      post:
        no_token: '[{"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=<%= ["foo"].concat([OAUTH_DATA["session_key"], OAUTH_DATA["session_key"]]).join(",") %>&type=client_cred: 
      post:
        no_token: '[null, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}, {"access_token":"<%= ACCESS_TOKEN %>","expires":4315}]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo,bar&type=client_cred: 
      post:
        no_token: '[null, null]'
    client_id=<%= APP_ID %>&client_secret=<%= SECRET %>&sessions=foo&type=client_cred: 
      post:
        no_token: '[null]'



# -- Subscription Responses -- 
  /<%= APP_ID %>/subscriptions:
    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token:
          code: 200
    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token: '{"error":{"type":"Exception","message":"(#2200) subscription validation failed"}}'
    callback_url=foo&fields=name&object=user&verify_token=<%= SUBSCRIPTION_DATA["verify_token"] %>:
      post: 
        with_token: '{"error":{"type":"Exception","message":"(#100) callback_url URL is not properly formatted"}}'
    object=user:
      delete:
        with_token:
          code: 200
    object=kittens:
      delete:
        with_token: '{"error":{"type":"Exception","message":"(#100) Invalid parameter"}}'
    no_args:
      delete: 
        with_token:
          code: 200
      get:
        with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'


    callback_url=<%= SUBSCRIPTION_DATA["subscription_path"] %>:
      get:
        with_token: '{"data":[{"callback_url":"http://oauth.twoalex.com/subscriptions", "fields":["name"], "object":"user", "active":true}]}'

# -- Mock Item Responses --

  /MOCK_FEED_ITEM/likes:
    no_args:
      post:
        with_token: '{"id": "MOCK_LIKE"}'
        
  /MOCK_FEED_ITEM/comments:
    message=it's my comment!:
      post:
        with_token: '{"id": "MOCK_<PASSWORD>"}'
  
  /MOCK_FEED_ITEM:
    no_args:
      <<: *item_deleted
  
  /FEED_ITEM_CONTEXT:
    no_args: 
      <<: *item_deleted
      get:
        with_token: '{"link":"http://oauth.twoalex.com/", "name": "OAuth Playground"}'
  
  /FEED_ITEM_CATS:
    no_args:
      <<: *item_deleted
      get: 
        with_token: '{"message": "the cats are asleep"}'
  
  /FEED_ITEM_DELETE:
    no_args:
      <<: *item_deleted

  /FEED_ITEM_DELETE/likes:
    no_args:
      <<: *item_deleted
      post: 
        with_token: 'true'
            
  /MOCK_COMMENT:
    no_args:
      <<: *item_deleted
      get:
        with_token: "{\"message\": \"it's my comment!\"}"
  /MOCK_PHOTO:
    no_args:
      <<: *item_deleted
      get:
        with_token: "{\"name\": \"This is the test message\"}"
        
# -- Mock Test User Responses --
  /<%= APP_ID %>/accounts/test-users:
    installed=false:
      <<: *test_user_no_perms
    installed=false&permissions=read_stream:
      <<: *test_user_no_perms                                                                                                                                                            
    installed=true&permissions=read_stream:
      post:
        with_token: '{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
    installed=true&permissions=read_stream,user_interests:
      post:
        with_token: '{"id": "888888888", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}'
    no_args:
      get:
        with_token: '{"data":[{"id": "999999999", "access_token":"<%= ACCESS_TOKEN %>", "login_url":"https://www.facebook.com/platform/test_account.."}, {"id": "888888888", "access_token":"<KEY> "login_url":"https://www.facebook.com/platform/test_account.."}]}'
        
  /999999999:
    no_args:
      <<: *item_deleted

  /999999999/friends/888888888:
    no_args:
      post:
        with_token: 'true'


  /9999999991:
    no_args:
      delete:
        with_token: '{"error": {"type": "OAuthException", "message": "Error validating verification code."}}'
 
  /888888888:
    no_args:
      <<: *item_deleted   

  /888888888/friends/999999999:
    no_args:
      <<: *test_user_befriended


  /777777777:
    no_args:
      <<: *item_deleted

{'fraction_non_alphanumeric': 0.21814434093586038, 'fraction_numerical': 0.046337937680693865, 'mean_word_length': 3.561294261294261, 'pattern_counts': {'":': 440, '<': 218, '<?xml version=': 0, '>': 264, 'https://': 16, 'lorem ipsum': 0, 'www.': 10, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 22, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4111591', 'n_tokens_mistral': 14704, 'n_tokens_neox': 13206, 'n_words': 2064}