def testParseFile(self): """Read a history file and run a few tests.""" parser = opera.OperaGlobalHistoryParser() storage_writer = self._ParseFile(['global_history.dat'], parser) self.assertEqual(storage_writer.number_of_warnings, 0) self.assertEqual(storage_writer.number_of_events, 37) events = list(storage_writer.GetEvents()) expected_event_values = { 'data_type': 'opera:history:entry', 'description': 'First and Only Visit', 'timestamp': '2013-11-11 22:45:46.000000', 'title': 'Karl Bretaprins fær ellilífeyri - mbl.is', 'url': ('http://www.mbl.is/frettir/erlent/2013/11/11/' 'karl_bretaprins_faer_ellilifeyri/') } self.CheckEventValues(storage_writer, events[4], expected_event_values) expected_event_values = { 'data_type': 'opera:history:entry', 'timestamp': '2013-11-11 22:45:55.000000' } self.CheckEventValues(storage_writer, events[10], expected_event_values) expected_event_values = { 'data_type': 'opera:history:entry', 'timestamp': '2013-11-11 22:46:16.000000', 'title': ('10 Celebrities You Never Knew Were Abducted And Murdered ' 'By Andie MacDowell | The Onion - America\'s Finest News Source') } self.CheckEventValues(storage_writer, events[16], expected_event_values)
def testParseFile(self): """Read a history file and run a few tests.""" parser = opera.OperaGlobalHistoryParser() storage_writer = self._ParseFile(['global_history.dat'], parser) self.assertEqual(storage_writer.number_of_events, 37) events = list(storage_writer.GetEvents()) event = events[4] expected_timestamp = timelib.Timestamp.CopyFromString( '2013-11-11 22:45:46') self.assertEqual(event.timestamp, expected_timestamp) expected_message = ( 'http://www.mbl.is/frettir/erlent/2013/11/11/' 'karl_bretaprins_faer_ellilifeyri/ (Karl Bretaprins fær ellilífeyri' ' - mbl.is) [First and Only Visit]') expected_short_message = ( 'http://www.mbl.is/frettir/erlent/2013/11/11/' 'karl_bretaprins_faer_ellilifeyri/...') self._TestGetMessageStrings(event, expected_message, expected_short_message) event = events[10] expected_timestamp = timelib.Timestamp.CopyFromString( '2013-11-11 22:45:55') self.assertEqual(event.timestamp, expected_timestamp) event = events[16] expected_timestamp = timelib.Timestamp.CopyFromString( '2013-11-11 22:46:16') self.assertEqual(event.timestamp, expected_timestamp) expected_title = ( '10 Celebrities You Never Knew Were Abducted And Murdered ' 'By Andie MacDowell | The Onion - America\'s Finest News Source') self.assertEqual(event.title, expected_title)
def testParseFile(self): """Read a history file and run a few tests.""" parser_object = opera.OperaGlobalHistoryParser() test_file = self._GetTestFilePath([u'global_history.dat']) event_queue_consumer = self._ParseFile(parser_object, test_file) event_objects = self._GetEventObjectsFromQueue(event_queue_consumer) self.assertEqual(len(event_objects), 37) event_object = event_objects[4] expected_timestamp = timelib.Timestamp.CopyFromString( u'2013-11-11 22:45:46') self.assertEqual(event_object.timestamp, expected_timestamp) expected_msg = ( u'http://www.mbl.is/frettir/erlent/2013/11/11/' u'karl_bretaprins_faer_ellilifeyri/ (Karl Bretaprins fær ellilífeyri' u' - mbl.is) [First and Only Visit]') expected_msg_short = (u'http://www.mbl.is/frettir/erlent/2013/11/11/' u'karl_bretaprins_faer_ellilifeyri/...') self._TestGetMessageStrings(event_object, expected_msg, expected_msg_short) event_object = event_objects[10] expected_timestamp = timelib.Timestamp.CopyFromString( u'2013-11-11 22:45:55') self.assertEqual(event_object.timestamp, expected_timestamp) event_object = event_objects[16] expected_timestamp = timelib.Timestamp.CopyFromString( u'2013-11-11 22:46:16') self.assertEqual(event_object.timestamp, expected_timestamp) expected_title = ( u'10 Celebrities You Never Knew Were Abducted And Murdered ' u'By Andie MacDowell | The Onion - America\'s Finest News Source') self.assertEqual(event_object.title, expected_title)
def testParseFile(self): """Read a history file and run a few tests.""" parser = opera.OperaGlobalHistoryParser() storage_writer = self._ParseFile(['global_history.dat'], parser) self.assertEqual(storage_writer.number_of_warnings, 0) self.assertEqual(storage_writer.number_of_events, 37) events = list(storage_writer.GetEvents()) expected_event_values = {'timestamp': '2013-11-11 22:45:46.000000'} self.CheckEventValues(storage_writer, events[4], expected_event_values) expected_message = ( 'http://www.mbl.is/frettir/erlent/2013/11/11/' 'karl_bretaprins_faer_ellilifeyri/ (Karl Bretaprins fær ellilífeyri' ' - mbl.is) [First and Only Visit]') expected_short_message = ( 'http://www.mbl.is/frettir/erlent/2013/11/11/' 'karl_bretaprins_faer_ellilifeyri/...') event_data = self._GetEventDataOfEvent(storage_writer, events[4]) self._TestGetMessageStrings(event_data, expected_message, expected_short_message) expected_event_values = {'timestamp': '2013-11-11 22:45:55.000000'} self.CheckEventValues(storage_writer, events[10], expected_event_values) expected_event_values = { 'timestamp': '2013-11-11 22:46:16.000000', 'title': ('10 Celebrities You Never Knew Were Abducted And Murdered ' 'By Andie MacDowell | The Onion - America\'s Finest News Source') } self.CheckEventValues(storage_writer, events[16], expected_event_values)
def setUp(self): """Sets up the needed objects used throughout the test.""" self._parser = opera.OperaGlobalHistoryParser()
def setUp(self): """Sets up the needed objects used throughout the test.""" pre_obj = event.PreprocessObject() self._parser = opera.OperaGlobalHistoryParser(pre_obj, None)
def setUp(self): """Makes preparations before running an individual test.""" self._parser = opera.OperaGlobalHistoryParser()