def testProcess(self): """Test the Process function on a Test file.""" plugin_object = test.TestPlugin() storage_writer = self._ParseDatabaseFileWithPlugin([u'test.db'], plugin_object) # We should have 25 events in total. # - 25 Users createdDate events. self.assertEqual(25, len(storage_writer.events)) # Test the first users createdDate event. guessed_event = [ e for e in storage_writer.events if e.id == 5402612 and e.name == u'BBC Breaking News' ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1177252957.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.id, 5402612) self.assertEqual(test_event.name, u'BBC Breaking News') expected_message = (u'Id: 5402612 Name: BBC Breaking News') expected_message_short = (u'Id: 5402612 Name: BBC Breaking News...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short)
def testProcess(self): """Test the Process function on a Test file.""" plugin_object = test.TestPlugin() storage_writer = self._ParseDatabaseFileWithPlugin([u'test.db'], plugin_object) # We should have 3350 events in total. # - 1675 Usersstatuses createdDate events. # - 1675 Usersstatuses updatedAt events. self.assertEqual(3350, len(storage_writer.events)) # Test the first usersstatuses updatedAt event. guessed_event = [ e for e in storage_writer.events if e.user_id == 5402612 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1449070544.333328 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.user_id, 5402612) expected_message = (u'User_Id: 5402612') expected_message_short = (u'User_Id: 5402612...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first usersstatuses createdDate event. guessed_event = [ e for e in storage_writer.events if e.user_id == 5402612 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1177252957.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.user_id, 5402612) expected_message = (u'User_Id: 5402612') expected_message_short = (u'User_Id: 5402612...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short)
def testProcess(self): """Test the Process function on a Test file.""" plugin_object = test.TestPlugin() storage_writer = self._ParseDatabaseFileWithPlugin([u'test.db'], plugin_object) # We should have 50 events in total. # - 25 Users createdDate events. # - 25 Users updatedAt events. self.assertEqual(50, len(storage_writer.events)) # Test the first users updatedAt event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities is None and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 0 and e.followers_count == 19466932 and e.followers_count_fast == 0 and e.followers_count_normal == 0 and e.following == 0 and e.following_count == 3 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.id == 5402612 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'London, UK' and e.media_count is None and e.name == u'BBC Breaking News' and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/5402612/1398336837' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png' and e.profile_link_color_hex_triplet == 2052731 and e.protected == 0 and e.screen_name == u'BBCBreaking' and e.statuses_count == 26697 and e.structured_location is None and e.url == u'http://www.bbc.co.uk/news' and e.url_entities is None and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1449070544.333328 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertIsNone(test_event.bio_entities) self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) expected_description = ( u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.') self.assertEqual(test_event.description, expected_description) self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 0) self.assertEqual(test_event.followers_count, 19466932) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 0) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 3) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.id, 5402612) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'London, UK') self.assertIsNone(test_event.media_count) self.assertEqual(test_event.name, u'BBC Breaking News') self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/5402612/1398336837') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 2052731) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'BBCBreaking') self.assertEqual(test_event.statuses_count, 26697) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'http://www.bbc.co.uk/news') self.assertIsNone(test_event.url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Id: 5402612 Screen Name: BBCBreaking Profile Image Url: https://' u'pbs.twimg.com/profile_images/460740982498013184/wIPwMwru_normal.' u'png Profile Banner Url:' u'https://pbs.twimg.com/profile_banners/5402612/1398336837 Profile' u'Link Color Hex Triplet: 2052731 Name: BBC Breaking News' u'Location: London, UK Structured Location: None Description:' u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport. Url:' u'http://www.bbc.co.uk/news Url Entities: None Bio Entities: None' u'Protected: 0 Verified: 1 Following: 0 Device Following: 0' u'Advertiser Account Type: 0 Statuses Count: 26697 Media Count:' u'None Favorites Count: 0 Following Count: 3 Followers Count:' u'19466932 Followers Count Fast: 0 Followers Count Normal: 0 Could' u'Be Stale: 0 Is Lifeline Institution: 0 Has Collections: 0 Is' u'Translator: 0 Has Extended Profile Fields: 0 Extended Profile' u'Fields: None Pinned Tweet Id: None Business Profile State: 0' u'Analytics Type: 0') expected_message_short = ( u'Id: 5402612 Screen Name: BBCBreaking Profile Image Url:' u'https://pbs.twimg.com...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first users createdDate event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities == u'b'{}'' and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'How people build software' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 155 and e.followers_count == 742086 and e.followers_count_fast == 0 and e.followers_count_normal == 742086 and e.following == 0 and e.following_count == 172 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.id == 13334762 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'San Francisco, CA' and e.media_count == 33 and e.name == u'GitHub' and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/13334762/1415719104' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png' and e.profile_link_color_hex_triplet == 255 and e.protected == 0 and e.screen_name == u'github' and e.statuses_count == 3120 and e.structured_location is None and e.url == u'https://t.co/FoKGHcCyJJ' and e.url_entities == u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'' and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1202704910.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertEqual(test_event.bio_entities, u'b'{}'') self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) self.assertEqual(test_event.description, u'How people build software') self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 155) self.assertEqual(test_event.followers_count, 742086) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 742086) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 172) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.id, 13334762) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'San Francisco, CA') self.assertEqual(test_event.media_count, 33) self.assertEqual(test_event.name, u'GitHub') self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/13334762/1415719104') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 255) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'github') self.assertEqual(test_event.statuses_count, 3120) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'https://t.co/FoKGHcCyJJ') expected_url_entities = ( u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'') self.assertEqual(test_event.url_entities, expected_url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Id: 13334762 Screen Name: github Profile Image Url: https://pbs.' u'twimg.com/profile_images/616309728688238592/pBeeJQDQ_normal.png' u'Profile Banner Url:' u'https://pbs.twimg.com/profile_banners/13334762/1415719104' u'Profile Link Color Hex Triplet: 255 Name: GitHub Location: San' u'Francisco, CA Structured Location: None Description: How people' u'build software Url: https://t.co/FoKGHcCyJJ Url Entities: b'' u'{"urls":[{"url":"https:\\/\\/t.co\\/FoKGHcCy' u'JJ","rangeInDisplay.length":0,"displayURL":&' u'#34;github.com","rangeInDisplay.location":0,"exp' u'andedURL":"https:\\/\\/github.com","range.locati' u'on":0,"range.length":23}]}' Bio Entities:' u'b'{}' Protected: 0 Verified: 1 Following: 0 Device' u'Following: 0 Advertiser Account Type: 0 Statuses Count: 3120' u'Media Count: 33 Favorites Count: 155 Following Count: 172' u'Followers Count: 742086 Followers Count Fast: 0 Followers Count' u'Normal: 742086 Could Be Stale: 0 Is Lifeline Institution: 0 Has' u'Collections: 0 Is Translator: 0 Has Extended Profile Fields: 0' u'Extended Profile Fields: None Pinned Tweet Id: None Business' u'Profile State: 0 Analytics Type: 0') expected_message_short = ( u'Id: 13334762 Screen Name: github Profile Image Url:' u'https://pbs.twimg.com/pro...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short)
def testProcess(self): """Test the Process function on a Test file.""" plugin_object = test.TestPlugin() storage_writer = self._ParseDatabaseFileWithPlugin([u'test.db'], plugin_object) # We should have 184 events in total. # - 25 Users createdDate events. # - 25 Users updatedAt events. # - 67 Statuses date events. # - 67 Statuses updatedAt events. self.assertEqual(184, len(storage_writer.events)) # Test the first users updatedAt event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities is None and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 0 and e.followers_count == 19466932 and e.followers_count_fast == 0 and e.followers_count_normal == 0 and e.following == 0 and e.following_count == 3 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.id == 5402612 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'London, UK' and e.media_count is None and e.name == u'BBC Breaking News' and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/5402612/1398336837' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png' and e.profile_link_color_hex_triplet == 2052731 and e.protected == 0 and e.screen_name == u'BBCBreaking' and e.statuses_count == 26697 and e.structured_location is None and e.url == u'http://www.bbc.co.uk/news' and e.url_entities is None and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1449070544.333328 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertIsNone(test_event.bio_entities) self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) expected_description = ( u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.') self.assertEqual(test_event.description, expected_description) self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 0) self.assertEqual(test_event.followers_count, 19466932) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 0) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 3) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.id, 5402612) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'London, UK') self.assertIsNone(test_event.media_count) self.assertEqual(test_event.name, u'BBC Breaking News') self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/5402612/1398336837') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 2052731) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'BBCBreaking') self.assertEqual(test_event.statuses_count, 26697) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'http://www.bbc.co.uk/news') self.assertIsNone(test_event.url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Id: 5402612 Screen Name: BBCBreaking Profile Image Url: https://' u'pbs.twimg.com/profile_images/460740982498013184/wIPwMwru_normal.' u'png Profile Banner Url:' u'https://pbs.twimg.com/profile_banners/5402612/1398336837 Profile' u'Link Color Hex Triplet: 2052731 Name: BBC Breaking News' u'Location: London, UK Structured Location: None Description:' u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport. Url:' u'http://www.bbc.co.uk/news Url Entities: None Bio Entities: None' u'Protected: 0 Verified: 1 Following: 0 Device Following: 0' u'Advertiser Account Type: 0 Statuses Count: 26697 Media Count:' u'None Favorites Count: 0 Following Count: 3 Followers Count:' u'19466932 Followers Count Fast: 0 Followers Count Normal: 0 Could' u'Be Stale: 0 Is Lifeline Institution: 0 Has Collections: 0 Is' u'Translator: 0 Has Extended Profile Fields: 0 Extended Profile' u'Fields: None Pinned Tweet Id: None Business Profile State: 0' u'Analytics Type: 0') expected_message_short = ( u'Id: 5402612 Screen Name: BBCBreaking Profile Image Url:' u'https://pbs.twimg.com...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first users createdDate event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities == u'b'{}'' and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'How people build software' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 155 and e.followers_count == 742086 and e.followers_count_fast == 0 and e.followers_count_normal == 742086 and e.following == 0 and e.following_count == 172 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.id == 13334762 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'San Francisco, CA' and e.media_count == 33 and e.name == u'GitHub' and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/13334762/1415719104' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png' and e.profile_link_color_hex_triplet == 255 and e.protected == 0 and e.screen_name == u'github' and e.statuses_count == 3120 and e.structured_location is None and e.url == u'https://t.co/FoKGHcCyJJ' and e.url_entities == u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'' and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1202704910.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertEqual(test_event.bio_entities, u'b'{}'') self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) self.assertEqual(test_event.description, u'How people build software') self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 155) self.assertEqual(test_event.followers_count, 742086) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 742086) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 172) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.id, 13334762) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'San Francisco, CA') self.assertEqual(test_event.media_count, 33) self.assertEqual(test_event.name, u'GitHub') self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/13334762/1415719104') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 255) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'github') self.assertEqual(test_event.statuses_count, 3120) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'https://t.co/FoKGHcCyJJ') expected_url_entities = ( u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'') self.assertEqual(test_event.url_entities, expected_url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Id: 13334762 Screen Name: github Profile Image Url: https://pbs.' u'twimg.com/profile_images/616309728688238592/pBeeJQDQ_normal.png' u'Profile Banner Url:' u'https://pbs.twimg.com/profile_banners/13334762/1415719104' u'Profile Link Color Hex Triplet: 255 Name: GitHub Location: San' u'Francisco, CA Structured Location: None Description: How people' u'build software Url: https://t.co/FoKGHcCyJJ Url Entities: b'' u'{"urls":[{"url":"https:\\/\\/t.co\\/FoKGHcCy' u'JJ","rangeInDisplay.length":0,"displayURL":&' u'#34;github.com","rangeInDisplay.location":0,"exp' u'andedURL":"https:\\/\\/github.com","range.locati' u'on":0,"range.length":23}]}' Bio Entities:' u'b'{}' Protected: 0 Verified: 1 Following: 0 Device' u'Following: 0 Advertiser Account Type: 0 Statuses Count: 3120' u'Media Count: 33 Favorites Count: 155 Following Count: 172' u'Followers Count: 742086 Followers Count Fast: 0 Followers Count' u'Normal: 742086 Could Be Stale: 0 Is Lifeline Institution: 0 Has' u'Collections: 0 Is Translator: 0 Has Extended Profile Fields: 0' u'Extended Profile Fields: None Pinned Tweet Id: None Business' u'Profile State: 0 Analytics Type: 0') expected_message_short = ( u'Id: 13334762 Screen Name: github Profile Image Url:' u'https://pbs.twimg.com/pro...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first statuses date event. guessed_event = [ e for e in storage_writer.events if e.card is None and e.card_users is None and e.card_version == 0 and e.entities == u'b'{"mediaUrls":[{"thumbSizeWidth":150,"m' u'ediaID":"510031569718108160","largeSizeWidth"' u';:1024,"largeSizeHeight":768,"range.length":22,&' u'#34;url":"http:\\/\\/t.co\\/L7bjWue1A2","origina' u'lSizeHeight":0,"smallSizeWidth":340,"rangeInDisp' u'lay.location":14,"mediumSizeFeatures":{"faces' u'4;:[]},"range.location":14,"expandedURL":"ht' u'tp:\\/\\/twitter.com\\/HeatherMahalik\\/status\\/510031570397577' u'216\\/photo\\/1","rangeInDisplay.length":26,"ori' u'ginalSizeWidth":0,"mediaType":1,"largeSizeFeatur' u'es":{"faces":[]},"mediaURL":"https:\\/\\' u'/pbs.twimg.com\\/media\\/BxP_AqlIYAAyjn0.jpg","smallSize' u'Height":255,"smallSizeFeatures":{"faces":[]}' u',"thumbSizeHeight":150,"monetizable":false,"' u'mediumSizeHeight":450,"displayURL":"pic.twitter.' u'com\\/L7bjWue1A2","mediumSizeWidth":600}]}'' and e.extra_scribe_item is None and e.favorite_count == 3 and e.favorited == 0 and e.full_text_length == 0 and e.geotag is None and e.id == 510031570397577216 and e.include_in_profile_timeline == 1 and e.in_reply_to_status_id is None and e.in_reply_to_username is None and e.is_lifeline_alert == 0 and e.is_possibly_sensitive_appealable == 0 and e.is_truncated == 0 and e.lang == u'en' and e.possibly_sensitive == 0 and e.preview_length == 0 and e.primary_card_type == 0 and e.quoted_status_id is None and e.retweet_count == 2 and e.retweeted_status_id is None and e.source == u'<a href="http://twitter.com/download/iphone"' u'rel="nofollow">Twitter for iPhone</a>' and e.supplmental_language is None and e.text == u'Never forget. http://t.co/L7bjWue1A2' and e.user_id == 475222380 and e.withheld_in_countries is None and e.withheld_scope is None ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1410435976.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertIsNone(test_event.card) self.assertIsNone(test_event.card_users) self.assertEqual(test_event.card_version, 0) expected_entities = ( u'b'{"mediaUrls":[{"thumbSizeWidth":150,"m' u'ediaID":"510031569718108160","largeSizeWidth"' u';:1024,"largeSizeHeight":768,"range.length":22,&' u'#34;url":"http:\\/\\/t.co\\/L7bjWue1A2","origina' u'lSizeHeight":0,"smallSizeWidth":340,"rangeInDisp' u'lay.location":14,"mediumSizeFeatures":{"faces' u'4;:[]},"range.location":14,"expandedURL":"ht' u'tp:\\/\\/twitter.com\\/HeatherMahalik\\/status\\/510031570397577' u'216\\/photo\\/1","rangeInDisplay.length":26,"ori' u'ginalSizeWidth":0,"mediaType":1,"largeSizeFeatur' u'es":{"faces":[]},"mediaURL":"https:\\/\\' u'/pbs.twimg.com\\/media\\/BxP_AqlIYAAyjn0.jpg","smallSize' u'Height":255,"smallSizeFeatures":{"faces":[]}' u',"thumbSizeHeight":150,"monetizable":false,"' u'mediumSizeHeight":450,"displayURL":"pic.twitter.' u'com\\/L7bjWue1A2","mediumSizeWidth":600}]}'') self.assertEqual(test_event.entities, expected_entities) self.assertIsNone(test_event.extra_scribe_item) self.assertEqual(test_event.favorite_count, 3) self.assertEqual(test_event.favorited, 0) self.assertEqual(test_event.full_text_length, 0) self.assertIsNone(test_event.geotag) self.assertEqual(test_event.id, 510031570397577216) self.assertEqual(test_event.include_in_profile_timeline, 1) self.assertIsNone(test_event.in_reply_to_status_id) self.assertIsNone(test_event.in_reply_to_username) self.assertEqual(test_event.is_lifeline_alert, 0) self.assertEqual(test_event.is_possibly_sensitive_appealable, 0) self.assertEqual(test_event.is_truncated, 0) self.assertEqual(test_event.lang, u'en') self.assertEqual(test_event.possibly_sensitive, 0) self.assertEqual(test_event.preview_length, 0) self.assertEqual(test_event.primary_card_type, 0) self.assertIsNone(test_event.quoted_status_id) self.assertEqual(test_event.retweet_count, 2) self.assertIsNone(test_event.retweeted_status_id) expected_source = ( u'<a href="http://twitter.com/download/iphone"' u'rel="nofollow">Twitter for iPhone</a>') self.assertEqual(test_event.source, expected_source) self.assertIsNone(test_event.supplmental_language) expected_text = (u'Never forget. http://t.co/L7bjWue1A2') self.assertEqual(test_event.text, expected_text) self.assertEqual(test_event.user_id, 475222380) self.assertIsNone(test_event.withheld_in_countries) self.assertIsNone(test_event.withheld_scope) expected_message = ( u'Id: 510031570397577216 Text: Never forget.' u'http://t.co/L7bjWue1A2 User Id: 475222380 In Reply To Status Id:' u'None Retweeted Status Id: None Geotag: None Entities: b'{' u'4;mediaUrls":[{"thumbSizeWidth":150,"mediaID"' u';:"510031569718108160","largeSizeWidth":1024,' u'4;largeSizeHeight":768,"range.length":22,"url' u'4;:"http:\\/\\/t.co\\/L7bjWue1A2","originalSizeHeigh' u't":0,"smallSizeWidth":340,"rangeInDisplay.locati' u'on":14,"mediumSizeFeatures":{"faces":[]},' u'4;range.location":14,"expandedURL":"http:\\/\\/t' u'witter.com\\/HeatherMahalik\\/status\\/510031570397577216\\/phot' u'o\\/1","rangeInDisplay.length":26,"originalSizeW' u'idth":0,"mediaType":1,"largeSizeFeatures":{&' u'#34;faces":[]},"mediaURL":"https:\\/\\/pbs.twimg' u'.com\\/media\\/BxP_AqlIYAAyjn0.jpg","smallSizeHeight"' u';:255,"smallSizeFeatures":{"faces":[]},"thum' u'bSizeHeight":150,"monetizable":false,"mediumSize' u'Height":450,"displayURL":"pic.twitter.com\\/L7bj' u'Wue1A2","mediumSizeWidth":600}]}' Card: None' u'Card Users: None Primary Card Type: 0 Card Version: 0 Retweet' u'Count: 2 Favorite Count: 3 Favorited: 0 Extra Scribe Item: None' u'Withheld Scope: None Withheld In Countries: None In Reply To' u'Username: None Possibly Sensitive: 0 Is Possibly Sensitive' u'Appealable: 0 Is Lifeline Alert: 0 Is Truncated: 0 Preview' u'Length: 0 Full Text Length: 0 Lang: en Supplmental Language:' u'None Include In Profile Timeline: 1 Quoted Status Id: None' u'Source: <a href="http://twitter.com/download/iphone"' u'rel="nofollow">Twitter for iPhone</a>') expected_message_short = (u'Id: 510031570397577216 Text: Never forget.' u'http://t.co/L7bjWue1A2 User Id: 47...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first statuses updatedAt event. guessed_event = [ e for e in storage_writer.events if e.card is None and e.card_users is None and e.card_version == 0 and e.entities == u'b'{"mediaUrls":[{"thumbSizeWidth":150,"m' u'ediaID":"666269245739692034","largeSizeWidth"' u';:590,"largeSizeHeight":295,"range.length":23,&#' u'34;url":"https:\\/\\/t.co\\/VtVaTY4Lh4","origina' u'lSizeHeight":0,"smallSizeWidth":340,"rangeInDisp' u'lay.location":91,"mediumSizeFeatures":{"faces' u'4;:[{"y":116,"w":62,"x":139,"h":' u'62}]},"range.location":100,"expandedURL":"ht' u'tp:\\/\\/twitter.com\\/PacktPub\\/status\\/666269245827747840\\/' u'photo\\/1","rangeInDisplay.length":26,"originalS' u'izeWidth":0,"mediaType":1,"largeSizeFeatures"' u';:{"faces":[{"y":116,"w":62,"x":' u'139,"h":62}]},"mediaURL":"https:\\/\\/pbs.tw' u'img.com\\/media\\/CT8QWVUU8AIIptM.png","smallSizeHeight&' u'#34;:170,"smallSizeFeatures":{"faces":[{"y&#' u'34;:66,"w":35,"x":80,"h":35}]},"thum' u'bSizeHeight":150,"monetizable":false,"mediumSize' u'Height":295,"displayURL":"pic.twitter.com\\/VtVa' u'TY4Lh4","mediumSizeWidth":590}],"urls":[{' u'4;url":"https:\\/\\/t.co\\/f4aNishzqk","rangeInD' u'isplay.length":14,"displayURL":"bit.ly\\/20JGoj8' u'","rangeInDisplay.location":76,"expandedURL"' u':"http:\\/\\/bit.ly\\/20JGoj8","range.location":' u'76,"range.length":23}]}'' and e.extra_scribe_item is None and e.favorite_count == 0 and e.favorited == 0 and e.full_text_length == 0 and e.geotag is None and e.id == 666269245827747840 and e.include_in_profile_timeline == 1 and e.in_reply_to_status_id is None and e.in_reply_to_username is None and e.is_lifeline_alert == 0 and e.is_possibly_sensitive_appealable == 0 and e.is_truncated == 0 and e.lang == u'en' and e.possibly_sensitive == 0 and e.preview_length == 0 and e.primary_card_type == 0 and e.quoted_status_id is None and e.retweet_count == 0 and e.retweeted_status_id is None and e.source == u'<a href="http://sproutsocial.com"' u'rel="nofollow">Sprout Social</a>' and e.supplmental_language is None and e.text == u'We don't care how you spend your $5 voucher - we just want' u'to hear from you https://t.co/f4aNishzqk https://t.co/VtVaTY4Lh4' and e.user_id == 17778401 and e.withheld_in_countries is None and e.withheld_scope is None ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1449070777.569438 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertIsNone(test_event.card) self.assertIsNone(test_event.card_users) self.assertEqual(test_event.card_version, 0) expected_entities = ( u'b'{"mediaUrls":[{"thumbSizeWidth":150,"m' u'ediaID":"666269245739692034","largeSizeWidth"' u';:590,"largeSizeHeight":295,"range.length":23,&#' u'34;url":"https:\\/\\/t.co\\/VtVaTY4Lh4","origina' u'lSizeHeight":0,"smallSizeWidth":340,"rangeInDisp' u'lay.location":91,"mediumSizeFeatures":{"faces' u'4;:[{"y":116,"w":62,"x":139,"h":' u'62}]},"range.location":100,"expandedURL":"ht' u'tp:\\/\\/twitter.com\\/PacktPub\\/status\\/666269245827747840\\/' u'photo\\/1","rangeInDisplay.length":26,"originalS' u'izeWidth":0,"mediaType":1,"largeSizeFeatures"' u';:{"faces":[{"y":116,"w":62,"x":' u'139,"h":62}]},"mediaURL":"https:\\/\\/pbs.tw' u'img.com\\/media\\/CT8QWVUU8AIIptM.png","smallSizeHeight&' u'#34;:170,"smallSizeFeatures":{"faces":[{"y&#' u'34;:66,"w":35,"x":80,"h":35}]},"thum' u'bSizeHeight":150,"monetizable":false,"mediumSize' u'Height":295,"displayURL":"pic.twitter.com\\/VtVa' u'TY4Lh4","mediumSizeWidth":590}],"urls":[{' u'4;url":"https:\\/\\/t.co\\/f4aNishzqk","rangeInD' u'isplay.length":14,"displayURL":"bit.ly\\/20JGoj8' u'","rangeInDisplay.location":76,"expandedURL"' u':"http:\\/\\/bit.ly\\/20JGoj8","range.location":' u'76,"range.length":23}]}'') self.assertEqual(test_event.entities, expected_entities) self.assertIsNone(test_event.extra_scribe_item) self.assertEqual(test_event.favorite_count, 0) self.assertEqual(test_event.favorited, 0) self.assertEqual(test_event.full_text_length, 0) self.assertIsNone(test_event.geotag) self.assertEqual(test_event.id, 666269245827747840) self.assertEqual(test_event.include_in_profile_timeline, 1) self.assertIsNone(test_event.in_reply_to_status_id) self.assertIsNone(test_event.in_reply_to_username) self.assertEqual(test_event.is_lifeline_alert, 0) self.assertEqual(test_event.is_possibly_sensitive_appealable, 0) self.assertEqual(test_event.is_truncated, 0) self.assertEqual(test_event.lang, u'en') self.assertEqual(test_event.possibly_sensitive, 0) self.assertEqual(test_event.preview_length, 0) self.assertEqual(test_event.primary_card_type, 0) self.assertIsNone(test_event.quoted_status_id) self.assertEqual(test_event.retweet_count, 0) self.assertIsNone(test_event.retweeted_status_id) expected_source = ( u'<a href="http://sproutsocial.com"' u'rel="nofollow">Sprout Social</a>') self.assertEqual(test_event.source, expected_source) self.assertIsNone(test_event.supplmental_language) expected_text = ( u'We don't care how you spend your $5 voucher - we just want' u'to hear from you https://t.co/f4aNishzqk https://t.co/VtVaTY4Lh4' ) self.assertEqual(test_event.text, expected_text) self.assertEqual(test_event.user_id, 17778401) self.assertIsNone(test_event.withheld_in_countries) self.assertIsNone(test_event.withheld_scope) expected_message = ( u'Id: 666269245827747840 Text: We don't care how you spend' u'your $5 voucher - we just want to hear from you' u'https://t.co/f4aNishzqk https://t.co/VtVaTY4Lh4 User Id:' u'17778401 In Reply To Status Id: None Retweeted Status Id: None' u'Geotag: None Entities: b'{"mediaUrls":[{"thumbSi' u'zeWidth":150,"mediaID":"666269245739692034",' u'"largeSizeWidth":590,"largeSizeHeight":295,"' u'range.length":23,"url":"https:\\/\\/t.co\\/VtVaT' u'Y4Lh4","originalSizeHeight":0,"smallSizeWidth' u'4;:340,"rangeInDisplay.location":91,"mediumSizeFeatu' u'res":{"faces":[{"y":116,"w":62,"' u'x":139,"h":62}]},"range.location":100,"e' u'xpandedURL":"http:\\/\\/twitter.com\\/PacktPub\\/status' u'\\/666269245827747840\\/photo\\/1","rangeInDisplay.length' u'":26,"originalSizeWidth":0,"mediaType":1,' u'4;largeSizeFeatures":{"faces":[{"y":116,"' u';w":62,"x":139,"h":62}]},"mediaURL":' u'"https:\\/\\/pbs.twimg.com\\/media\\/CT8QWVUU8AIIptM.png"' u';,"smallSizeHeight":170,"smallSizeFeatures":{' u'4;faces":[{"y":66,"w":35,"x":80,"' u';h":35}]},"thumbSizeHeight":150,"monetizable"' u';:false,"mediumSizeHeight":295,"displayURL":"' u';pic.twitter.com\\/VtVaTY4Lh4","mediumSizeWidth":590' u'}],"urls":[{"url":"https:\\/\\/t.co\\/f4aNis' u'hzqk","rangeInDisplay.length":14,"displayURL"' u';:"bit.ly\\/20JGoj8","rangeInDisplay.location":7' u'6,"expandedURL":"http:\\/\\/bit.ly\\/20JGoj8",&#' u'34;range.location":76,"range.length":23}]}'' u'Card: None Card Users: None Primary Card Type: 0 Card Version: 0' u'Retweet Count: 0 Favorite Count: 0 Favorited: 0 Extra Scribe' u'Item: None Withheld Scope: None Withheld In Countries: None In' u'Reply To Username: None Possibly Sensitive: 0 Is Possibly' u'Sensitive Appealable: 0 Is Lifeline Alert: 0 Is Truncated: 0' u'Preview Length: 0 Full Text Length: 0 Lang: en Supplmental' u'Language: None Include In Profile Timeline: 1 Quoted Status Id:' u'None Source: <a href="http://sproutsocial.com"' u'rel="nofollow">Sprout Social</a>') expected_message_short = ( u'Id: 666269245827747840 Text: We don't care how you spend' u'your $5 voucher - we...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short)
def testProcess(self): """Test the Process function on a Test file.""" plugin_object = test.TestPlugin() storage_writer = self._ParseDatabaseFileWithPlugin([u'test.db'], plugin_object) # We should have 100 events in total. # - 25 Users createdDate events. # - 25 Users id events. # - 25 Users name events. # - 25 Users updatedAt events. self.assertEqual(100, len(storage_writer.events)) # Test the first users id event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities is None and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 0 and e.followers_count == 19466932 and e.followers_count_fast == 0 and e.followers_count_normal == 0 and e.following == 0 and e.following_count == 3 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'London, UK' and e.media_count is None and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/5402612/1398336837' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png' and e.profile_link_color_hex_triplet == 2052731 and e.protected == 0 and e.screen_name == u'BBCBreaking' and e.statuses_count == 26697 and e.structured_location is None and e.url == u'http://www.bbc.co.uk/news' and e.url_entities is None and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 5402612 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertIsNone(test_event.bio_entities) self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) expected_description = ( u'Breaking news alerts and updates from the BBC. For news,' u'features, analysis follow @BBCWorld (international) or @BBCNews' u'(UK). Latest sport news @BBCSport.') self.assertEqual(test_event.description, expected_description) self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 0) self.assertEqual(test_event.followers_count, 19466932) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 0) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 3) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'London, UK') self.assertIsNone(test_event.media_count) self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/5402612/1398336837') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/460740982498013184/wIPwMwru' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 2052731) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'BBCBreaking') self.assertEqual(test_event.statuses_count, 26697) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'http://www.bbc.co.uk/news') self.assertIsNone(test_event.url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Screen Name: BBCBreaking Profile Image Url: https://pbs.twimg.co' u'm/profile_images/460740982498013184/wIPwMwru_normal.png Profile' u'Banner Url:' u'https://pbs.twimg.com/profile_banners/5402612/1398336837 Profile' u'Link Color Hex Triplet: 2052731 Location: London, UK Structured' u'Location: None Description: Breaking news alerts and updates' u'from the BBC. For news, features, analysis follow @BBCWorld' u'(international) or @BBCNews (UK). Latest sport news @BBCSport.' u'Url: http://www.bbc.co.uk/news Url Entities: None Bio Entities:' u'None Protected: 0 Verified: 1 Following: 0 Device Following: 0' u'Advertiser Account Type: 0 Statuses Count: 26697 Media Count:' u'None Favorites Count: 0 Following Count: 3 Followers Count:' u'19466932 Followers Count Fast: 0 Followers Count Normal: 0 Could' u'Be Stale: 0 Is Lifeline Institution: 0 Has Collections: 0 Is' u'Translator: 0 Has Extended Profile Fields: 0 Extended Profile' u'Fields: None Pinned Tweet Id: None Business Profile State: 0' u'Analytics Type: 0') expected_message_short = ( u'Screen Name: BBCBreaking Profile Image Url:' u'https://pbs.twimg.com/profile_ima...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first users name event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities == u'b'{}'' and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'How people build software' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 155 and e.followers_count == 742086 and e.followers_count_fast == 0 and e.followers_count_normal == 742086 and e.following == 0 and e.following_count == 172 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'San Francisco, CA' and e.media_count == 33 and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/13334762/1415719104' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png' and e.profile_link_color_hex_triplet == 255 and e.protected == 0 and e.screen_name == u'github' and e.statuses_count == 3120 and e.structured_location is None and e.url == u'https://t.co/FoKGHcCyJJ' and e.url_entities == u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'' and e.verified == 1 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: GitHub expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertEqual(test_event.bio_entities, u'b'{}'') self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) self.assertEqual(test_event.description, u'How people build software') self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 155) self.assertEqual(test_event.followers_count, 742086) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 742086) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 172) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'San Francisco, CA') self.assertEqual(test_event.media_count, 33) self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/13334762/1415719104') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/616309728688238592/pBeeJQDQ' u'_normal.png') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 255) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'github') self.assertEqual(test_event.statuses_count, 3120) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'https://t.co/FoKGHcCyJJ') expected_url_entities = ( u'b'{"urls":[{"url":"https:\\/\\/t.co\\/Fo' u'KGHcCyJJ","rangeInDisplay.length":0,"displayURL&' u'#34;:"github.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"https:\\/\\/github.com","range.' u'location":0,"range.length":23}]}'') self.assertEqual(test_event.url_entities, expected_url_entities) self.assertEqual(test_event.verified, 1) expected_message = ( u'Screen Name: github Profile Image Url: https://pbs.twimg.com/pro' u'file_images/616309728688238592/pBeeJQDQ_normal.png Profile' u'Banner Url:' u'https://pbs.twimg.com/profile_banners/13334762/1415719104' u'Profile Link Color Hex Triplet: 255 Location: San Francisco, CA' u'Structured Location: None Description: How people build software' u'Url: https://t.co/FoKGHcCyJJ Url Entities: b'{"urls"' u':[{"url":"https:\\/\\/t.co\\/FoKGHcCyJJ","ra' u'ngeInDisplay.length":0,"displayURL":"github.com&' u'#34;,"rangeInDisplay.location":0,"expandedURL":&' u'#34;https:\\/\\/github.com","range.location":0,"' u'range.length":23}]}' Bio Entities: b'{}'' u'Protected: 0 Verified: 1 Following: 0 Device Following: 0' u'Advertiser Account Type: 0 Statuses Count: 3120 Media Count: 33' u'Favorites Count: 155 Following Count: 172 Followers Count:' u'742086 Followers Count Fast: 0 Followers Count Normal: 742086' u'Could Be Stale: 0 Is Lifeline Institution: 0 Has Collections: 0' u'Is Translator: 0 Has Extended Profile Fields: 0 Extended Profile' u'Fields: None Pinned Tweet Id: None Business Profile State: 0' u'Analytics Type: 0') expected_message_short = (u'Screen Name: github Profile Image Url:' u'https://pbs.twimg.com/profile_images/6...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first users updatedAt event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities == u'b'{"urls":[{"url":"http:\\/\\/t.co\\/Ndc' u'gVZ9Un6","rangeInDisplay.length":0,"displayURL&#' u'34;:"tompohl.com\\/bio.png","rangeInDisplay.location' u'":0,"expandedURL":"http:\\/\\/tompohl.com\\/bio.' u'png","range.location":0,"range.length":22}]}' u''' and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'http://t.co/NdcgVZ9Un6' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 267 and e.followers_count == 681 and e.followers_count_fast == 0 and e.followers_count_normal == 0 and e.following == 0 and e.following_count == 661 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'Des Moines, Iowa' and e.media_count is None and e.pinned_tweet_id is None and e.profile_banner_url is None and e.profile_image_url == u'https://pbs.twimg.com/profile_images/378800000102859706/83b823ec' u'53247f689a48d5d3bdeeeb16_normal.jpeg' and e.profile_link_color_hex_triplet == 33972 and e.protected == 0 and e.screen_name == u'tompohl' and e.statuses_count == 4922 and e.structured_location is None and e.url == u'http://t.co/FN9hFrj9Mm' and e.url_entities == u'b'{"urls":[{"url":"http:\\/\\/t.co\\/FN9' u'hFrj9Mm","rangeInDisplay.length":0,"displayURL&#' u'34;:"tompohl.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"http:\\/\\/tompohl.com","range.' u'location":0,"range.length":22}]}'' and e.verified == 0 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1449070777.562435 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) expected_bio_entities = ( u'b'{"urls":[{"url":"http:\\/\\/t.co\\/Ndc' u'gVZ9Un6","rangeInDisplay.length":0,"displayURL&#' u'34;:"tompohl.com\\/bio.png","rangeInDisplay.location' u'":0,"expandedURL":"http:\\/\\/tompohl.com\\/bio.' u'png","range.location":0,"range.length":22}]}' u''') self.assertEqual(test_event.bio_entities, expected_bio_entities) self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) self.assertEqual(test_event.description, u'http://t.co/NdcgVZ9Un6') self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 267) self.assertEqual(test_event.followers_count, 681) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 0) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 661) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'Des Moines, Iowa') self.assertIsNone(test_event.media_count) self.assertIsNone(test_event.pinned_tweet_id) self.assertIsNone(test_event.profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/378800000102859706/83b823ec' u'53247f689a48d5d3bdeeeb16_normal.jpeg') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 33972) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'tompohl') self.assertEqual(test_event.statuses_count, 4922) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'http://t.co/FN9hFrj9Mm') expected_url_entities = ( u'b'{"urls":[{"url":"http:\\/\\/t.co\\/FN9' u'hFrj9Mm","rangeInDisplay.length":0,"displayURL&#' u'34;:"tompohl.com","rangeInDisplay.location":0,&#' u'34;expandedURL":"http:\\/\\/tompohl.com","range.' u'location":0,"range.length":22}]}'') self.assertEqual(test_event.url_entities, expected_url_entities) self.assertEqual(test_event.verified, 0) expected_message = ( u'Screen Name: tompohl Profile Image Url: https://pbs.twimg.com/pr' u'ofile_images/378800000102859706/83b823ec53247f689a48d5d3bdeeeb16' u'_normal.jpeg Profile Banner Url: None Profile Link Color Hex' u'Triplet: 33972 Location: Des Moines, Iowa Structured Location:' u'None Description: http://t.co/NdcgVZ9Un6 Url:' u'http://t.co/FN9hFrj9Mm Url Entities: b'{"urls":[{' u'4;url":"http:\\/\\/t.co\\/FN9hFrj9Mm","rangeInDi' u'splay.length":0,"displayURL":"tompohl.com",&' u'#34;rangeInDisplay.location":0,"expandedURL":"ht' u'tp:\\/\\/tompohl.com","range.location":0,"range.' u'length":22}]}' Bio Entities: b'{"urls":[{' u'4;url":"http:\\/\\/t.co\\/NdcgVZ9Un6","rangeInDi' u'splay.length":0,"displayURL":"tompohl.com\\/bio.' u'png","rangeInDisplay.location":0,"expandedURL' u'4;:"http:\\/\\/tompohl.com\\/bio.png","range.locatio' u'n":0,"range.length":22}]}' Protected: 0' u'Verified: 0 Following: 0 Device Following: 0 Advertiser Account' u'Type: 0 Statuses Count: 4922 Media Count: None Favorites Count:' u'267 Following Count: 661 Followers Count: 681 Followers Count' u'Fast: 0 Followers Count Normal: 0 Could Be Stale: 0 Is Lifeline' u'Institution: 0 Has Collections: 0 Is Translator: 0 Has Extended' u'Profile Fields: 0 Extended Profile Fields: None Pinned Tweet Id:' u'None Business Profile State: 0 Analytics Type: 0') expected_message_short = (u'Screen Name: tompohl Profile Image Url:' u'https://pbs.twimg.com/profile_images/...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short) # Test the first users createdDate event. guessed_event = [ e for e in storage_writer.events if e.advertiser_account_type == 0 and e.analytics_type == 0 and e.bio_entities == u'b'{}'' and e.business_profile_state == 0 and e.could_be_stale == 0 and e.description == u'Director of @SenatorLeahy Center for Digital Investigation,' u'@Champlainedu Professor, Forensic Examiner - Vermont ICAC,' u'Marathoner, Bonsai enthusiast' and e.device_following == 0 and e.extended_profile_fields is None and e.favorites_count == 52 and e.followers_count == 1165 and e.followers_count_fast == 0 and e.followers_count_normal == 0 and e.following == 0 and e.following_count == 411 and e.has_collections == 0 and e.has_extended_profile_fields == 0 and e.is_lifeline_institution == 0 and e.is_translator == 0 and e.location == u'Burlington, Vermont' and e.media_count is None and e.pinned_tweet_id is None and e.profile_banner_url == u'https://pbs.twimg.com/profile_banners/15378399/1400611105' and e.profile_image_url == u'https://pbs.twimg.com/profile_images/659825753/Rajewski_Pic_norm' u'al.jpg' and e.profile_link_color_hex_triplet == 39321 and e.protected == 0 and e.screen_name == u'jtrajewski' and e.statuses_count == 3096 and e.structured_location is None and e.url == u'http://t.co/GqYJCMnCeq' and e.url_entities == u'b'{"urls":[{"url":"http:\\/\\/t.co\\/GqY' u'JCMnCeq","rangeInDisplay.length":0,"displayURL&#' u'34;:"jonrajewski.com\\/cyberblog","rangeInDisplay.lo' u'cation":0,"expandedURL":"http:\\/\\/jonrajewski.' u'com\\/cyberblog","range.location":0,"range.lengt' u'h":22}]}'' and e.verified == 0 ][0] position = storage_writer.index(guessed_event) test_event = storage_writer.events[position] # TODO add expected formatted timestamp for timestamp in database: 1215702054.0 expected_timestamp = timelib.Timestamp.CopyFromString(u'TODO') self.assertEqual(test_event.timestamp, expected_timestamp) self.assertEqual(test_event.timestamp_desc, eventdata.EventTimestamp.CREATION_TIME) self.assertEqual(test_event.advertiser_account_type, 0) self.assertEqual(test_event.analytics_type, 0) self.assertEqual(test_event.bio_entities, u'b'{}'') self.assertEqual(test_event.business_profile_state, 0) self.assertEqual(test_event.could_be_stale, 0) expected_description = ( u'Director of @SenatorLeahy Center for Digital Investigation,' u'@Champlainedu Professor, Forensic Examiner - Vermont ICAC,' u'Marathoner, Bonsai enthusiast') self.assertEqual(test_event.description, expected_description) self.assertEqual(test_event.device_following, 0) self.assertIsNone(test_event.extended_profile_fields) self.assertEqual(test_event.favorites_count, 52) self.assertEqual(test_event.followers_count, 1165) self.assertEqual(test_event.followers_count_fast, 0) self.assertEqual(test_event.followers_count_normal, 0) self.assertEqual(test_event.following, 0) self.assertEqual(test_event.following_count, 411) self.assertEqual(test_event.has_collections, 0) self.assertEqual(test_event.has_extended_profile_fields, 0) self.assertEqual(test_event.is_lifeline_institution, 0) self.assertEqual(test_event.is_translator, 0) self.assertEqual(test_event.location, u'Burlington, Vermont') self.assertIsNone(test_event.media_count) self.assertIsNone(test_event.pinned_tweet_id) expected_profile_banner_url = ( u'https://pbs.twimg.com/profile_banners/15378399/1400611105') self.assertEqual(test_event.profile_banner_url, expected_profile_banner_url) expected_profile_image_url = ( u'https://pbs.twimg.com/profile_images/659825753/Rajewski_Pic_norm' u'al.jpg') self.assertEqual(test_event.profile_image_url, expected_profile_image_url) self.assertEqual(test_event.profile_link_color_hex_triplet, 39321) self.assertEqual(test_event.protected, 0) self.assertEqual(test_event.screen_name, u'jtrajewski') self.assertEqual(test_event.statuses_count, 3096) self.assertIsNone(test_event.structured_location) self.assertEqual(test_event.url, u'http://t.co/GqYJCMnCeq') expected_url_entities = ( u'b'{"urls":[{"url":"http:\\/\\/t.co\\/GqY' u'JCMnCeq","rangeInDisplay.length":0,"displayURL&#' u'34;:"jonrajewski.com\\/cyberblog","rangeInDisplay.lo' u'cation":0,"expandedURL":"http:\\/\\/jonrajewski.' u'com\\/cyberblog","range.location":0,"range.lengt' u'h":22}]}'') self.assertEqual(test_event.url_entities, expected_url_entities) self.assertEqual(test_event.verified, 0) expected_message = ( u'Screen Name: jtrajewski Profile Image Url: https://pbs.twimg.com' u'/profile_images/659825753/Rajewski_Pic_normal.jpg Profile Banner' u'Url: https://pbs.twimg.com/profile_banners/15378399/1400611105' u'Profile Link Color Hex Triplet: 39321 Location: Burlington,' u'Vermont Structured Location: None Description: Director of' u'@SenatorLeahy Center for Digital Investigation, @Champlainedu' u'Professor, Forensic Examiner - Vermont ICAC, Marathoner, Bonsai' u'enthusiast Url: http://t.co/GqYJCMnCeq Url Entities: b'{"' u';urls":[{"url":"http:\\/\\/t.co\\/GqYJCMnCeq"' u';,"rangeInDisplay.length":0,"displayURL":"jo' u'nrajewski.com\\/cyberblog","rangeInDisplay.location"' u':0,"expandedURL":"http:\\/\\/jonrajewski.com\\/cyber' u'blog","range.location":0,"range.length":22}]' u'}' Bio Entities: b'{}' Protected: 0 Verified: 0' u'Following: 0 Device Following: 0 Advertiser Account Type: 0' u'Statuses Count: 3096 Media Count: None Favorites Count: 52' u'Following Count: 411 Followers Count: 1165 Followers Count Fast:' u'0 Followers Count Normal: 0 Could Be Stale: 0 Is Lifeline' u'Institution: 0 Has Collections: 0 Is Translator: 0 Has Extended' u'Profile Fields: 0 Extended Profile Fields: None Pinned Tweet Id:' u'None Business Profile State: 0 Analytics Type: 0') expected_message_short = (u'Screen Name: jtrajewski Profile Image Url:' u'https://pbs.twimg.com/profile_imag...') self._TestGetMessageStrings(test_event, expected_message, expected_message_short)