def test_parse_without_exceptions(self): for line in self.loglines: msg = logengine.createMessage(line) self.assertTrue(msg, "unparseable: %s" % line) self.assertFalse(msg.facility is None, "Message has no facility: {0!r}\n{1!r}" .format(line, vars(msg)))
def test_insert(self): for line in self.loglines: database = Mock('cursor') database.fetchone = lambda: [random.randint(1, 10000)] def execute(sql, params=()): return sql % params database.execute = execute message = logengine.createMessage(line) self.assertTrue(message, "unparseable: %s" % line) logengine.insert_message(message, database, {}, {}, {}, {}, {}, {})
def test_should_parse_facility_correctly(self): msg = logengine.createMessage(self.message) self.assertEquals(msg.facility, self.facility)
def test_should_parse_timestamp_correctly(self): msg = logengine.createMessage(self.message) self.assertEquals(msg.time, self.timestamp)
def test_should_parse_without_exception(self): msg = logengine.createMessage(self.message)
def _line_doesnt_parse(line): msg = logengine.createMessage(line) assert msg is None, "line shouldn't be parseable: %s" % line
def test_should_parse_description_correctly(self): msg = logengine.createMessage(self.message) self.assertEquals(msg.description, self.description)
def test_should_parse_mnemonic_correctly(self): msg = logengine.createMessage(self.message) self.assertEquals(msg.mnemonic, self.mnemonic)
def test_should_parse_priority_correctly(self): msg = logengine.createMessage(self.message) self.assertEquals(msg.priorityid, self.priority)