def testHappyPath_Warning(self):
        print 'testHappyPath_Warning'
        testData = gen_happy_path()
        lines = testData.split('\n')

        # Check the keyword header line in CSV
        try:
            csv = logFilter.LogFilterCSV({})
        except Exception as err:
            sys.stderr.write('Invalid configuration file:%s\n' % err)
            return 1
        log_dict = csv.parse_log_entry(lines[1])

        self.failUnless('date' in log_dict)
        self.failUnless('level' in log_dict)
        self.failUnless(log_dict['level'] == 'CMD')
        self.failUnless('a' in log_dict)
        self.failUnless(log_dict['a'] == 'b')
        self.failUnless('item' in log_dict)
        self.failUnless(log_dict['item'] == 'Good Stuff')
    def testMissingData(self):
        print 'testMissingData'
        testData = gen_missing_data()
        lines = testData.split('\n')

        # Check the keyword header line in CSV
        try:
            lf = logFilter.LogFilterCSV({})
        except Exception as err:
            sys.stderr.write('Invalid configuration file:%s\n' % err)
            return 1
        log_dict = lf.parse_log_entry(lines[0])

        self.failUnless('date' in log_dict)
        self.failUnless('level' in log_dict)
        self.failUnless(log_dict['level'] == 'DEBUG')
        self.failUnless('a' in log_dict)
        self.failUnless(log_dict['a'] == 'b')
        self.failUnless('item' in log_dict)
        self.failUnless(log_dict['item'] == 'Good Stuff')
    def testMixedData(self):
        print 'testMixedData'
        testData = gen_mixed_data()
        lines = testData.split('\n')

        # select only WARNING or higher
        log_filters = logFilter.LogFilters.copy()  # don't zap original!
        log_filters['level'] = 'WARNING'
        try:
            lf = logFilter.LogFilterCSV(log_filters)
        except Exception as err:
            sys.stderr.write('Invalid configuration file:%s\n' % err)
            return 1

        log_dict = lf.parse_log_entry(lines[0])
        self.failUnless(log_dict is None)

        log_dict = lf.parse_log_entry(lines[3])
        self.failUnless(log_dict != None)
        self.failUnless(log_dict['level'] == 'ERROR')
        self.failUnless('date' in log_dict)
    def testHappyPath_1(self):
        print 'testHappyPath'
        testData = gen_happy_path()
        lines = testData.split('\n')

        # Check the keyword header line in CSV
        try:
            csv = logFilter.LogFilterCSV({})
        except Exception as err:
            sys.stderr.write('Invalid configuration file:%s\n' % err)
            return 1
        csv.parse_log_entry(lines[0])
        print csv.log_keys()  # Sorted keys matching data

        self.failUnless('date' in csv.log_dict)
        self.failUnless('level' in csv.log_dict)
        self.failUnless(csv.log_dict['level'] == 'DEBUG')
        self.failUnless('a' in csv.log_dict)
        self.failUnless(csv.log_dict['a'] == 'b')
        self.failUnless('item' in csv.log_dict)
        self.failUnless(csv.log_dict['item'] == 'Good Stuff')