pork_sandwich 0.1.0

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/test/fakewebs.rb ADDED
@@ -0,0 +1,66 @@
1
+ config = YAML::load(File.open("#{File.dirname(__FILE__)}/../config/pork_config.yml"))
2
+ username = config['config']['twitter_auth']['username']
3
+ password = config['config']['twitter_auth']['password']
4
+
5
+ FakeWeb.allow_net_connect = false
6
+
7
+ # SEARCH METHOD
8
+ FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/521281029/DSC01483_-_Kopia_-_Kopia_normal.JPG","created_at":"Wed, 11 Nov 2009 17:52:11 +0000","from_user":"SamIsMarth","to_user_id":10186853,"text":"@sage2526 cool. I have to study to my german test... Have a nice evening ^^","id":5624810553,"from_user_id":72123474,"to_user":"sage2526","geo":null,"iso_language_code":"en","source":"<a href="http://twitter.com/">web</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"MarthIsGreat","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5624809937,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"<a href="http://help.twitter.com/index.php?pg=kb.page&id=75" rel="nofollow">txt</a>"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
9
+
10
+ FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?max_id=5624809937&rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/521281029/DSC01483_-_Kopia_-_Kopia_normal.JPG","created_at":"Wed, 11 Nov 2009 17:52:11 +0000","from_user":"EvanIsLucas","to_user_id":10186853,"text":"@sage2526 cool. I have to study to my german test... Have a nice evening ^^","id":5624810553,"from_user_id":72123474,"to_user":"sage2526","geo":null,"iso_language_code":"en","source":"<a href="http://twitter.com/">web</a>"},{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"LucasIsCheap","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5555,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"<a href="http://help.twitter.com/index.php?pg=kb.page&id=75" rel="nofollow">txt</a>"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
11
+
12
+ FakeWeb.register_uri(:any, "http://search.twitter.com/search.json?max_id=5555&rpp=100&q=test", :body => '{"results":[{"profile_image_url":"http://a3.twimg.com/profile_images/56115537/Andrew_-_small_normal.jpg","created_at":"Wed, 11 Nov 2009 17:52:09 +0000","from_user":"LucasIsCheap","to_user_id":null,"text":"Gearing up yo fail this calculus III test. Wish me luck!","id":5555,"from_user_id":842449,"geo":null,"iso_language_code":"en","source":"<a href="http://help.twitter.com/index.php?pg=kb.page&id=75" rel="nofollow">txt</a>"}],"max_id":5624810553,"since_id":0,"refresh_url":"?since_id=5624810553&q=test","next_page":"?page=2&max_id=5624810553&q=test","results_per_page":15,"page":1,"completed_in":0.040758,"query":"test"}')
13
+
14
+
15
+ # USER INFO METHOD
16
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/users/show/15019521.json", :body => '{"following":false,"statuses_count":260,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","status":{"in_reply_to_screen_name":null,"source":"web","created_at":"Tue Nov 10 15:22:43 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5590958294,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"},"geo_enabled":false,"profile_background_tile":false,"profile_background_color":"EDECE9","url":null,"verified":false,"profile_sidebar_fill_color":"E3E2DE","followers_count":132,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","friends_count":133,"profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","location":"Cambridge, MA","name":"Sam Gilbert","notifications":false,"favourites_count":0,"screen_name":"sam1vp","id":15019521,"utc_offset":-18000,"profile_text_color":"634047"}')
17
+
18
+ # FOLLLOWER IDS METHOD
19
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/followers/ids.json?user_id=15019521", :body => '[55555,4444,15019521]')
20
+
21
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/followers/ids.json?user_id=55555", :body => '[4444]')
22
+
23
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/followers/ids.json?user_id=4444", :body => '[333, 22, 1]')
24
+
25
+ # FOLLOWERS USER INFO METHOD
26
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=-1&user_id=15019521", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":55555,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"},{"following":false,"geo_enabled":false,"statuses_count":114,"description":"Atlantic senior editor, James Beard Award-winner, and curator of The Atlantic Food Channel.","profile_image_url":"http://a1.twimg.com/profile_images/130071282/corby_mug_yellow_normal.png","status":{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_screen_name":null,"source":"<a href=\"http://twitterfeed.com\" rel=\"nofollow\">twitterfeed</a>","created_at":"Mon Nov 09 16:51:45 +0000 2009","id":5562998741,"text":"LAST OF THE ROMANOS My favorite green beans are at end-of-season farmers markets. Try them with this secret sa.. http://bit.ly/10jqzl"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":4444,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":55555, "previous_cursor":0 }')
27
+
28
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=55555&user_id=15019521", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"},{"following":false,"geo_enabled":false,"statuses_count":114,"description":"Atlantic senior editor, James Beard Award-winner, and curator of The Atlantic Food Channel.","profile_image_url":"http://a1.twimg.com/profile_images/130071282/corby_mug_yellow_normal.png","status":{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_screen_name":null,"source":"<a href=\"http://twitterfeed.com\" rel=\"nofollow\">twitterfeed</a>","created_at":"Mon Nov 09 16:51:45 +0000 2009","id":5562998741,"text":"LAST OF THE ROMANOS My favorite green beans are at end-of-season farmers markets. Try them with this secret sa.. http://bit.ly/10jqzl"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":22,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
29
+
30
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=-1&user_id=55555", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
31
+
32
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=-1&user_id=4444", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
33
+
34
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=-1&user_id=333", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
35
+
36
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/followers.json?cursor=-1&user_id=22", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":1,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
37
+
38
+
39
+
40
+ # FRIEND IDS METHOD
41
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/friends/ids.json?user_id=15019521", :body => '[55555,4444,15019521]')
42
+
43
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/friends/ids.json?user_id=55555", :body => '[4444]')
44
+
45
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/friends/ids.json?user_id=4444", :body => '[333, 22, 1]')
46
+
47
+ # FRIEND USER INFO METHOD
48
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=-1&user_id=15019521", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":55555,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"},{"following":false,"geo_enabled":false,"statuses_count":114,"description":"Atlantic senior editor, James Beard Award-winner, and curator of The Atlantic Food Channel.","profile_image_url":"http://a1.twimg.com/profile_images/130071282/corby_mug_yellow_normal.png","status":{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_screen_name":null,"source":"<a href=\"http://twitterfeed.com\" rel=\"nofollow\">twitterfeed</a>","created_at":"Mon Nov 09 16:51:45 +0000 2009","id":5562998741,"text":"LAST OF THE ROMANOS My favorite green beans are at end-of-season farmers markets. Try them with this secret sa.. http://bit.ly/10jqzl"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":4444,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":55555, "previous_cursor":0 }')
49
+
50
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=55555&user_id=15019521", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"},{"following":false,"geo_enabled":false,"statuses_count":114,"description":"Atlantic senior editor, James Beard Award-winner, and curator of The Atlantic Food Channel.","profile_image_url":"http://a1.twimg.com/profile_images/130071282/corby_mug_yellow_normal.png","status":{"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"favorited":false,"in_reply_to_screen_name":null,"source":"<a href=\"http://twitterfeed.com\" rel=\"nofollow\">twitterfeed</a>","created_at":"Mon Nov 09 16:51:45 +0000 2009","id":5562998741,"text":"LAST OF THE ROMANOS My favorite green beans are at end-of-season farmers markets. Try them with this secret sa.. http://bit.ly/10jqzl"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":22,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
51
+
52
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=-1&user_id=55555", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
53
+
54
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=-1&user_id=4444", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
55
+
56
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=-1&user_id=333", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":333,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
57
+
58
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/friends.json?cursor=-1&user_id=22", :body => '{"users":[{"following":null,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme1/bg.png","description":"Bars, bartenders & imbibing in Beantown","verified":false,"profile_link_color":"0000ff","status":{"in_reply_to_screen_name":null,"source":"<a href=\"http://www.tweetdeck.com/\" rel=\"nofollow\">TweetDeck</a>","created_at":"Wed Nov 11 23:16:53 +0000 2009","in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5632679977,"favorited":false,"text":"What does one absolutely HAVE to do when visiting Seattle?"},"profile_background_tile":false,"profile_background_color":"9ae4e8","url":"http://drinkboston.com/","followers_count":343,"profile_sidebar_fill_color":"e0ff92","statuses_count":112,"created_at":"Sat Jun 13 11:24:47 +0000 2009","friends_count":141,"time_zone":"Quito","profile_sidebar_border_color":"87bc44","protected":false,"profile_image_url":"http://a3.twimg.com/profile_images/428011343/lauren_normal.jpg","notifications":null,"favourites_count":0,"location":"Boston, MA","name":"Lauren Clark","screen_name":"Drinkboston","id":1,"geo_enabled":false,"utc_offset":-18000,"profile_text_color":"000000"}], "next_cursor":0, "previous_cursor":0 }')
59
+
60
+ # USER TWEETS METHOD
61
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/user_timeline.json?count=200&user_id=15019521", :body => %^[{"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5590958294,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"}, {"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5590958294,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"} ]^)
62
+
63
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/user_timeline.json?max_id=5590958294&count=200&user_id=15019521", :body => %^[{"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5590958294,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"}, {"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5555,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"} ]^)
64
+
65
+ FakeWeb.register_uri(:any, "http://#{username}:#{password}@twitter.com/statuses/user_timeline.json?max_id=5555&count=200&user_id=15019521", :body => %^[{"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5590958294,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"}, {"in_reply_to_screen_name":null,"source":"web","geo":null,"created_at":"Tue Nov 10 15:22:43 +0000 2009","user":{"following":false,"profile_background_image_url":"http://s.twimg.com/a/1257800794/images/themes/theme3/bg.gif","description":"","profile_link_color":"088253","profile_background_tile":false,"followers_count":132,"profile_background_color":"EDECE9","url":null,"friends_count":133,"profile_sidebar_fill_color":"E3E2DE","notifications":false,"statuses_count":260,"favourites_count":0,"created_at":"Thu Jun 05 15:47:02 +0000 2008","time_zone":"Eastern Time (US & Canada)","profile_sidebar_border_color":"D3D2CF","protected":false,"profile_image_url":"http://a1.twimg.com/profile_images/55090134/samiamdrseuss_normal.jpg","geo_enabled":false,"location":"Cambridge, MA","name":"Sam Gilbert","screen_name":"sam1vp","id":15019521,"verified":false,"utc_offset":-18000,"profile_text_color":"634047"},"in_reply_to_user_id":null,"in_reply_to_status_id":null,"truncated":false,"id":5555,"favorited":false,"text":"NEW POST (on my new, if still half-baked site), in which I complain about having too much money: www.samgilbert.org"} ]^)
66
+
data/test/log_test.rb ADDED
@@ -0,0 +1,14 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class LogTest < Test::Unit::TestCase
4
+ context "A default Log" do
5
+ setup do
6
+ @log = Pork::Log.new(STDOUT,{:researcher => "Researcher", :project => "Project"})
7
+ end
8
+
9
+ should "be able to be created" do
10
+ @log.inspect
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,51 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class PullerTest < Test::Unit::TestCase
4
+ context "An authenticated default puller" do
5
+ setup do
6
+ $SAVER = Pork::Saver.new
7
+ @p = Pork::Puller.new($AUTH)
8
+ @user_info_keys = ["created_at", "description", "favourites_count", "followers_count", "following", "friends_count", "geo_enabled", "id", "location", "name", "notifications", "profile_background_color", "profile_background_image_url", "profile_background_tile", "profile_image_url", "profile_link_color", "profile_sidebar_border_color", "profile_sidebar_fill_color", "profile_text_color", "protected", "screen_name", "status", "statuses_count", "time_zone", "url", "utc_offset", "verified"]
9
+ db_user_object = TwitterAccount.create({:twitter_id => 15019521,:screen_name => 'sam1vp'})
10
+ @test_user = Pork::TwitterUser.new(:twitter_id => 15019521, :db_object => db_user_object)
11
+ $LOG = Logger.new(STDOUT)
12
+ $LOG.level = Logger::INFO
13
+ end
14
+
15
+ should "be able to be created" do
16
+ @p.inspect
17
+ end
18
+
19
+ should "be able to pull followers for a given user" do
20
+ @pull_hash = @p.pull(@test_user, &FOLLOWERS)
21
+ assert_equal 55555, TwitterAccount.find(@pull_hash[:follower_relationship_db_ids].first).twitter_id
22
+ end
23
+
24
+ should "be able to pull an array of follower ids for a given user_id" do
25
+ @pull_hash = @p.pull(@test_user, &FOLLOWER_IDS)
26
+ assert_equal @pull_hash[:follower_relationship_db_ids].class, Array
27
+ end
28
+
29
+ should "be able to pull friends for a given user" do
30
+ @pull_hash = @p.pull(@test_user, &FRIENDS)
31
+ assert_equal 22, TwitterAccount.find(@pull_hash[:friend_relationship_db_ids].first).twitter_id
32
+ end
33
+
34
+ should "be able to pull an array of friend IDs for a given user_id" do
35
+ @pull_hash = @p.pull(@test_user, &FRIEND_IDS)
36
+ assert_equal @pull_hash[:friend_relationship_db_ids].class, Array
37
+ end
38
+
39
+ should "be able to pull tweets from a user's timeline for a given user" do
40
+ @pull_hash = @p.pull(@test_user, &TWEETS)
41
+ assert_equal 5590958294, Tweet.find(@pull_hash[:db_ids].first).status_id
42
+ end
43
+
44
+
45
+ should "be able to pull info from twitter for a user" do
46
+ @pull_hash = @p.pull(@test_user, &ACCOUNT_INFO)
47
+ assert_equal @pull_hash[:pull_data].screen_name, 'sam1vp'
48
+ end
49
+
50
+ end
51
+ end
@@ -0,0 +1,46 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class ReactionProcessorTest < Test::Unit::TestCase
4
+ context "A default saver" do
5
+ setup do
6
+ db_user_object = TwitterAccount.create({:twitter_id => 15019521,:screen_name => 'sam1vp'})
7
+ @processor = Pork::ReactionProcessor.new(Pork::TwitterUser.new(:twitter_id => 15019521, :db_object=> db_user_object))
8
+ end
9
+ should "be able to be created" do
10
+ @processor.inspect
11
+ end
12
+ context "given a tweet with '@username ...'" do
13
+ tweet = Factory.build(:reply_tweet)
14
+ should "be able to extract a reply screen_name" do
15
+ assert_equal "username", @processor.parse_tweet_for_influentials(tweet)[:reply_screen_name]
16
+ end
17
+ end
18
+ context "given a tweet with '... @username ...'" do
19
+ tweet = Factory.build(:mention_tweet)
20
+ should "be able to extract a mention screen_name" do
21
+ assert_equal "username", @processor.parse_tweet_for_influentials(tweet)[:mention_screen_names].first
22
+ end
23
+ end
24
+ context "given a tweet with 'RT @username ...'" do
25
+ tweet = Factory.build(:retweet1_tweet)
26
+ should "be able to extract a retweet influential" do
27
+ assert_equal "username", @processor.parse_tweet_for_influentials(tweet)[:rt_screen_names].first
28
+ end
29
+ end
30
+ context "given a tweet with '...RT @username ...'" do
31
+ tweet = Factory.build(:retweet2_tweet)
32
+ should "be able to extract a retweet influential" do
33
+ assert_equal "username", @processor.parse_tweet_for_influentials(tweet)[:rt_screen_names].first
34
+ end
35
+ end
36
+ context "given a tweet with '...@username...@username...'" do
37
+ tweet = Factory.build(:double_mention_tweet)
38
+ should "be able to extract a two mention influential" do
39
+ assert_equal "username1", @processor.parse_tweet_for_influentials(tweet)[:mention_screen_names].first
40
+ assert_equal "username2", @processor.parse_tweet_for_influentials(tweet)[:mention_screen_names].last
41
+ end
42
+ end
43
+ end
44
+
45
+ end
46
+
@@ -0,0 +1,110 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class SaverTest < Test::Unit::TestCase
4
+ context "A default saver" do
5
+ setup do
6
+ @saver = Pork::Saver.new
7
+ $LOG = Logger.new(STDOUT)
8
+ $LOG.level = Logger::INFO
9
+ end
10
+ # context "when saving a unique tweet" do
11
+ # setup do
12
+ # @tweet_size = Tweet.all.size
13
+ # @tweet = Factory.build(:tweet)
14
+ # @saver.save(@tweet, &TWEET_SAVE)
15
+ # end
16
+ # should "allow the tweet to be saved" do
17
+ # assert_equal @tweet_size+1, Tweet.all.size
18
+ # end
19
+ # end
20
+ context "when saving a unique user" do
21
+ setup do
22
+ @twitter_account_size = TwitterAccount.all.size
23
+ @twitter_account = Factory.build(:twitter_account)
24
+ @saver.save(@twitter_account, &TWITTER_ACCOUNT_SAVE)
25
+ end
26
+
27
+ should "allow the user to be saved" do
28
+ assert_equal @twitter_account_size+1, TwitterAccount.all.size
29
+ end
30
+ end
31
+
32
+ context "when saving a relationship" do
33
+ setup do
34
+ @twitter_relationship_size = TwitterRelationship.all.size
35
+ @friend = Pork::TwitterUser.new(:db_object => Factory.create(:twitter_account))
36
+ @follower = Pork::TwitterUser.new(:db_object => Factory.create(:twitter_account))
37
+ @saver.save(:friend => @friend, :follower => @follower, &RELATIONSHIP_SAVE)
38
+ end
39
+
40
+ should "allow the relationship to be saved" do
41
+ assert_equal @twitter_relationship_size+1, TwitterRelationship.all.size
42
+ end
43
+ end
44
+ context "when saving a tweet_reaction" do
45
+ setup do
46
+ @tweet_reaction_size = TweetReaction.all.size
47
+ @tweet_reaction = Factory.build(:tweet_reaction)
48
+ @saver.save(@tweet_reaction, &REACTION_SAVE)
49
+ end
50
+
51
+ should "allow the reaction to be saved" do
52
+ assert_equal @tweet_reaction_size+1, TweetReaction.all.size
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+
59
+ context "A saver with taggings" do
60
+ setup do
61
+ @rules = {:check_validation => false, :create_relationships => false, :language_detect => false, "tags" => {"tag" => "tag1"}}
62
+ @saver = Pork::Saver.new(rules = @rules)
63
+ end
64
+ # context "when saving a unique tweet" do
65
+ # setup do
66
+ # @tweet = Factory.build(:tweet)
67
+ # @saver.save(@tweet, &TWEET_SAVE)
68
+ # end
69
+ #
70
+ # should "have the tag soved on the tweet" do
71
+ # assert_contains Tweet.find_by_status_id(@tweet.status_id).tag_list, @rules["tags"]["tag"]
72
+ # end
73
+ # end
74
+
75
+ context "when saving a unique user" do
76
+ setup do
77
+ @twitter_account = Factory.build(:twitter_account)
78
+ @saver.save(@twitter_account, &TWITTER_ACCOUNT_SAVE)
79
+ end
80
+
81
+ should "allow the user to be tagged" do
82
+ assert_contains TwitterAccount.find_by_screen_name(@twitter_account.screen_name).tag_list, @rules["tags"]["tag"]
83
+ end
84
+ end
85
+
86
+ context "when saving a relationship" do
87
+ setup do
88
+ @friend = Pork::TwitterUser.new(:db_object => Factory.create(:twitter_account))
89
+ @follower = Pork::TwitterUser.new(:db_object => Factory.create(:twitter_account))
90
+ @saver.save(:friend => @friend, :follower => @follower, &RELATIONSHIP_SAVE)
91
+ end
92
+
93
+ should "allow the relationship to be tagged" do
94
+ assert_contains TwitterRelationship.last.tag_list,@rules["tags"]["tag"]
95
+ end
96
+ end
97
+ context "when saving a tweet_reaction" do
98
+ setup do
99
+ @tweet_reaction = Factory.build(:tweet_reaction)
100
+ @saver.save(@tweet_reaction, &REACTION_SAVE)
101
+ end
102
+
103
+ should "allow the reaction to be tagged" do
104
+ assert_contains TweetReaction.last.tag_list,@rules["tags"]["tag"]
105
+ end
106
+ end
107
+
108
+ end
109
+
110
+ end
data/test/schema.rb ADDED
@@ -0,0 +1,120 @@
1
+ require 'active_record'
2
+ require 'acts-as-taggable-on'
3
+
4
+ #Include modules from acts_as_taggable_on
5
+ ActiveRecord::Base.send :include, ActiveRecord::Acts::TaggableOn
6
+ ActiveRecord::Base.send :include, ActiveRecord::Acts::Tagger
7
+
8
+ #Setup connection to db and logging
9
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:")
10
+ #ActiveRecord::Base.logger = Logger.new(File.open('database.log', 'a'))
11
+
12
+
13
+ ActiveRecord::Schema.define(:version => 0) do
14
+ create_table :twitter_accounts do |t|
15
+ t.integer :twitter_id, :limit => 8
16
+ t.integer :twitter_id_for_search, :limit => 8
17
+ t.string :screen_name
18
+ t.string :name
19
+ t.string :location
20
+
21
+ t.datetime :time_of_user_creation #need timezone
22
+
23
+ t.text :description
24
+ t.string :profile_image_url
25
+ t.string :url
26
+ t.boolean :protected
27
+ t.integer :followers_count
28
+ t.string :profile_background_color
29
+ t.string :profile_text_color
30
+ t.string :profile_link_color
31
+ t.string :profile_sidebar_fill_color
32
+ t.string :profile_sidebar_border_color
33
+ t.integer :friends_count
34
+ t.integer :favourites_count
35
+ t.integer :utc_offset
36
+ t.string :time_zone
37
+ t.string :profile_background_image_url
38
+ t.boolean :profile_background_tile
39
+ t.integer :statuses_count
40
+ t.boolean :notifications
41
+ t.boolean :verified
42
+ t.timestamps
43
+ end
44
+
45
+ create_table :tweets do |t|
46
+ t.string :text, :null => false
47
+ t.datetime :time_of_tweet #need timestamp
48
+ t.string :from_user, :null => false
49
+ t.integer :to_user_id
50
+ t.integer :to_user_id_search
51
+ t.string :to_user
52
+ t.integer :status_id, :null => false, :limit => 8
53
+ t.integer :from_user_id_search, :limit => 8
54
+ t.string :iso_language_code
55
+ t.string :source
56
+ t.string :profile_image_url
57
+ t.integer :twitter_account_id, :limit => 8
58
+ t.boolean :truncated
59
+
60
+ t.timestamps
61
+ end
62
+
63
+ create_table :trends do |t|
64
+ t.string :topic
65
+ t.timestamps
66
+ end
67
+
68
+ create_table :tags do |t|
69
+ t.column :name, :string
70
+ end
71
+
72
+ create_table :taggings do |t|
73
+ t.column :tag_id, :integer
74
+ t.column :taggable_id, :integer
75
+ t.column :tagger_id, :integer
76
+ t.column :tagger_type, :string
77
+
78
+ t.column :taggable_type, :string
79
+ t.column :context, :string
80
+
81
+ t.column :created_at, :datetime
82
+ end
83
+
84
+ create_table :twitter_relationships do |t|
85
+ t.integer :follower_id, :null => false, :dependent => :destroy, :limit => 8
86
+ t.integer :friend_id, :null => false, :dependent => :destroy, :limit => 8
87
+ t.boolean :current
88
+ t.boolean :complete_follower_set
89
+ t.boolean :complete_friend_set
90
+ t.timestamps
91
+ end
92
+
93
+
94
+ create_table :trends_tweets, :id => false do |t|
95
+ t.integer :tweet_id, :null => false, :dependent => :destroy, :limit => 8
96
+ t.integer :trend_id, :null => false, :dependent => :destroy, :limit => 8
97
+ end
98
+
99
+ create_table :trends_twitter_accounts, :id => false do |t|
100
+ t.integer :trend_id, :null => false, :dependent => :destroy, :limit => 8
101
+ t.integer :twitter_account_id, :null => false, :dependent => :destroy, :limit => 8
102
+ end
103
+
104
+ create_table :reactions do |t|
105
+ t.string :reaction_type, :limit => 20
106
+ t.float :value
107
+ end
108
+
109
+ create_table :tweet_reactions do |t|
110
+ t.integer :initiator_id, :null => false, :dependent => :destroy, :limit => 8
111
+ t.integer :responder_id, :null => false, :dependent => :destroy, :limit => 8
112
+ t.integer :tweet_id, :null => false, :dependent => :destroy, :limit => 8
113
+ t.references :reaction
114
+ t.boolean :current
115
+ t.timestamps
116
+ end
117
+
118
+
119
+ end
120
+
@@ -0,0 +1,50 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class SearchTest < Test::Unit::TestCase
4
+ context "A search object with query, desired_count, and from_user" do
5
+ setup do
6
+ @search = Pork::Search.new('test', {:from_user => "from_user", :desired_count => 1})
7
+ end
8
+
9
+ should "let me read query" do
10
+ assert_equal "test", @search.query
11
+ end
12
+
13
+ should "let me read count" do
14
+ assert_equal 1, @search.desired_count
15
+ end
16
+
17
+ should "let me read from_user" do
18
+ assert_equal "from_user", @search.from_user
19
+ end
20
+
21
+ should "let me read db_ids_created" do
22
+ assert_equal [], @search.db_ids_created
23
+ end
24
+
25
+ end
26
+ context "A search object where query = 'test'" do
27
+ setup do
28
+ @search = Pork::Search.new('test')
29
+ end
30
+
31
+ should "be able to do an historical pull" do
32
+ result = @search.historical_pull
33
+ assert_equal true, result
34
+ assert_equal 5, @search.current_count
35
+ end
36
+ context "and desired_count = 2" do
37
+ setup do
38
+ @search = Pork::Search.new('test', {:desired_count => 4})
39
+ end
40
+
41
+ should "be able to do an historical pull for only 4 tweets" do
42
+ result = @search.historical_pull
43
+ assert_equal true, result
44
+ assert_equal 4, @search.current_count
45
+ end
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'fakeweb'
4
+ require 'shoulda'
5
+ require 'factory_girl'
6
+ require "#{File.dirname(__FILE__)}/schema"
7
+ require 'twitter'
8
+ require "#{File.dirname(__FILE__)}/fakewebs"
9
+ require 'rr'
10
+
11
+
12
+
13
+
14
+ require "#{File.dirname(__FILE__)}/../lib/pork"
15
+
16
+ class Test::Unit::TestCase
17
+ include RR::Adapters::TestUnit
18
+ config = YAML::load(File.open("#{File.dirname(__FILE__)}/../config/pork_config.yml"))
19
+ $AUTH = Pork::Auth.new(config['config']['twitter_auth']['username'], config['config']['twitter_auth']['password'], :user_agent => 'web_ecology_project').auth
20
+ end
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
@@ -0,0 +1,66 @@
1
+ require "#{File.dirname(__FILE__)}/test_helper"
2
+
3
+ class TwitterUserTest < Test::Unit::TestCase
4
+ context "A TwitterUser with 'full' attributes" do
5
+ setup do
6
+ @user = Pork::TwitterUser.new({:twitter_id => 15019521, :twitter_screen_name => 'user_name', :crawled => true, :user_info => 'user_info', :db_object => 'db_object'})
7
+
8
+ end
9
+
10
+ should "be able to reveal its twitter_id" do
11
+ assert_equal 15019521, @user.twitter_id
12
+ end
13
+ should "be able to reveal its screen_name" do
14
+ assert_equal 'user_name', @user.twitter_screen_name
15
+ end
16
+ should "be able to reveal its crawl status " do
17
+ assert_equal true, @user.crawled
18
+ end
19
+ should "be able to reveal its user info " do
20
+ assert_equal 'user_info', @user.user_info
21
+ end
22
+ should "be able to reveal its db object" do
23
+ assert_equal 'db_object', @user.db_object
24
+ end
25
+
26
+ should "not be able to update user data with the pull user data method" do
27
+ @user.pull_account_info
28
+ assert_equal 'user_info', @user.user_info
29
+ assert_equal 'user_name', @user.twitter_screen_name
30
+ end
31
+
32
+ should "be able to update user data" do
33
+ @user.update_account_info
34
+ assert_equal 'Sam Gilbert', @user.user_info[:name]
35
+ assert_equal 'sam1vp', @user.twitter_screen_name
36
+ end
37
+
38
+ should "be able to pull tweets" do
39
+ @user.pull_tweets
40
+ assert_equal 5590958294, Tweet.find(@user.tweet_db_ids[1]).status_id
41
+ end
42
+
43
+ should "be able to pull followers" do
44
+ @user.pull_followers
45
+ assert_equal @user.db_object.id, TwitterRelationship.find(@user.follower_relationship_db_ids[3]).friend_id
46
+ end
47
+
48
+ should "be able to pull friends" do
49
+ @user.pull_friends
50
+ assert_equal @user.db_object.id, TwitterRelationship.find(@user.friend_relationship_db_ids[3]).follower_id
51
+ end
52
+
53
+ should "be able to pull friend_ids" do
54
+ @user.pull_friend_ids
55
+ assert_equal @user.db_object.id, TwitterRelationship.find(@user.friend_relationship_db_ids.first).follower_id
56
+ end
57
+
58
+ should "be able to pull follower_ids" do
59
+ @user.pull_follower_ids
60
+ assert_equal @user.db_object.id, TwitterRelationship.find(@user.follower_relationship_db_ids.first).friend_id
61
+ end
62
+
63
+
64
+ end
65
+
66
+ end