def test_get_investigate_suppression_rules(self):

        oSuppressionList = suppression_list.create()

        oSuppression = suppression.create('Sup0')
        oSuppression.add_suppressed_warning('Hello')
        oSuppression.add_suppressed_warning('Hello 2')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup1')
        oSuppression.add_suppressed_warning('Goodbye')
        oSuppression.investigate = 'Investigate1'
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup2')
        oSuppression.add_suppressed_warning('Morning')
        oSuppression.investigate = 'Investigate2'
        oSuppressionList.add_suppression(oSuppression)

        lActual = oSuppressionList.get_investigate_suppression_rules()

        self.assertEqual(2, len(lActual))

        self.assertEqual('Sup1', lActual[0].get_warning_id())
        self.assertEqual('Sup2', lActual[1].get_warning_id())
    def test_get_suppressions_which_suppressed_a_warning_w_investigate_rules(self):

        oSuppressionList = suppression_list.create()

        oSuppression = suppression.create('Sup0')
        oSuppression.add_suppressed_warning('Hello')
        oSuppression.add_suppressed_warning('Hello 2')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup1')
        oSuppression.add_suppressed_warning('Goodbye')
        oSuppression.investigate = 'Investigate1'
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup2')
        oSuppression.add_suppressed_warning('Tomorrow')
        oSuppression.investigate = 'Investigate2'
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup3')
        oSuppression.add_suppressed_warning('Today')
        oSuppressionList.add_suppression(oSuppression)

        lActual = oSuppressionList.get_suppressions_which_suppressed_a_warning()

        self.assertEqual(2, len(lActual))

        self.assertEqual('Sup0', lActual[0].get_warning_id())
        self.assertEqual('Sup3', lActual[1].get_warning_id())
    def test_add_suppression_method(self):
        oSuppressionList = suppression_list.create()

        oSuppressionList.add_suppression(suppression.create('WID1'))
        oSuppressionList.add_suppression(suppression.create('WID2'))

        self.assertEqual('WID1', oSuppressionList.suppressions[0].warning_id)
        self.assertEqual('WID2', oSuppressionList.suppressions[1].warning_id)
def show(cla):

    oSupList = suppression_list.create()

    lLogFile = utils.read_log_file(cla.log_file)

    oWarnList = utils.create_warning_list(lLogFile, cla.log_file)

    display.results(cla.log_file, '<None>', oSupList, oWarnList)
    def test_get_number_of_suppressions(self):

        oSuppressionList = suppression_list.create()

        self.assertEqual(0, oSuppressionList.get_number_of_suppressions())

        oSuppressionList.add_suppression(suppression.create('WID1'))

        self.assertEqual(1, oSuppressionList.get_number_of_suppressions())

        oSuppressionList.add_suppression(suppression.create('WID2'))

        self.assertEqual(2, oSuppressionList.get_number_of_suppressions())
Beispiel #6
0
    def test_create_suppression_list_w_investigates(self):

        dSuppression = utils.read_suppression_file(
            os.path.join(os.path.dirname(__file__),
                         'investigate_suppress.yaml'))

        oActualSuppressionList = utils.create_suppression_list(dSuppression)

        oExpectedSuppressList = suppression_list.create()

        oSuppression = suppression.create('SYN001', 'This is the message',
                                          'jcleary', 'This is fine because...')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('SYN001', 'This is another message',
                                          '<None>', 'Just ignore this...')
        oSuppression.investigate = True
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('NO_ID',
                                          'Some warning without a proper ID',
                                          '<None>', 'This is fine...')
        oSuppression.investigate = True
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create(
            'NO_ID', 'This is another NO_ID suppression rule', '<None>',
            'Both this and the other NO_ID must be present.')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('CMP2001',
                                          'This is some compile warning',
                                          'jcleary', 'Just because...')
        oSuppression.investigate = True
        oExpectedSuppressList.suppressions.append(oSuppression)

        self.assertEqual(5, len(oActualSuppressionList.suppressions))
        oExpectedSuppressList.suppressions.append(oSuppression)

        for i in range(5):
            oExpected = oExpectedSuppressList.suppressions[i]
            oActual = oActualSuppressionList.suppressions[i]

            self.assertEqual(oExpected.get_warning_id(),
                             oActual.get_warning_id())
            self.assertEqual(oExpected.get_message(), oActual.get_message())
            self.assertEqual(oExpected.get_author(), oActual.get_author())
            self.assertEqual(oExpected.get_comment(), oActual.get_comment())
            self.assertEqual(oExpected.get_investigate(),
                             oActual.get_investigate())
    def test_get_suppressions_which_did_not_suppress_a_warning(self):

        oSuppressionList = suppression_list.create()

        oSuppression = suppression.create('Sup0')
        oSuppression.add_suppressed_warning('Hello')
        oSuppression.add_suppressed_warning('Hello 2')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup1')
        oSuppression.add_suppressed_warning('Goodbye')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create('Sup2')
        oSuppressionList.add_suppression(oSuppression)

        lActual = oSuppressionList.get_suppressions_which_did_not_suppress_a_warning()

        self.assertEqual(1, len(lActual))

        self.assertEqual('Sup2', lActual[0].get_warning_id())
    def test_get_suppressions_which_suppressed_a_warning(self):

        oSuppressionList = suppression_list.create()

        oSuppression = suppression.create()
        oSuppression.add_suppressed_warning('Hello')
        oSuppression.add_suppressed_warning('Hello 2')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create()
        oSuppression.add_suppressed_warning('Goodbye')
        oSuppressionList.add_suppression(oSuppression)

        oSuppression = suppression.create()
        oSuppressionList.add_suppression(oSuppression)

        lActual = oSuppressionList.get_suppressions_which_suppressed_a_warning()

        self.assertEqual(2, len(lActual))

        self.assertEqual('Hello', lActual[0].get_suppressed_warnings()[0])
        self.assertEqual('Hello 2', lActual[0].get_suppressed_warnings()[1])
        self.assertEqual('Goodbye', lActual[1].get_suppressed_warnings()[0])
 def test_empty_suppression_list_creation(self):
     oSuppressionList = suppression_list.create()
     self.assertEqual([], oSuppressionList.suppressions)
Beispiel #10
0
    def test_create_suppression_list(self):

        dSuppression = {}
        dSuppression['suppress'] = {}
        dSuppression['suppress']['rules'] = {}

        dSuppression['suppress']['rules']['SYN001'] = []
        dRule = {}
        dRule['msg'] = 'This is the message'
        dRule['author'] = 'jcleary'
        dRule['comment'] = 'This is fine because...'
        dSuppression['suppress']['rules']['SYN001'].append(dRule)
        dRule = {}
        dRule['msg'] = 'This is another message'
        dRule['comment'] = 'Just ignore this...'
        dSuppression['suppress']['rules']['SYN001'].append(dRule)

        dSuppression['suppress']['rules']['NO_ID'] = []
        dRule = {}
        dRule['msg'] = 'Some warning without a proper ID'
        dRule['comment'] = 'This is fine...'
        dSuppression['suppress']['rules']['NO_ID'].append(dRule)

        dSuppression['suppress']['rules']['CMP2001'] = []
        dRule = {}
        dRule['msg'] = 'This is some compile warning'
        dRule['author'] = 'jcleary'
        dRule['comment'] = 'Just because...'
        dSuppression['suppress']['rules']['CMP2001'].append(dRule)

        dSuppression['suppress']['rules']['NO_COMMENT'] = []
        dRule = {}
        dRule['msg'] = 'This rule has no comment'
        dSuppression['suppress']['rules']['NO_COMMENT'].append(dRule)

        oActualSuppressionList = utils.create_suppression_list(dSuppression)

        oExpectedSuppressList = suppression_list.create()

        oSuppression = suppression.create('SYN001', 'This is the message',
                                          'jcleary', 'This is fine because...')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('SYN001', 'This is another message',
                                          '<None>', 'Just ignore this...')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('NO_ID',
                                          'Some warning without a proper ID',
                                          '<None>', 'This is fine...')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('CMP2001',
                                          'This is some compile warning',
                                          'jcleary', 'Just because...')
        oExpectedSuppressList.suppressions.append(oSuppression)

        oSuppression = suppression.create('NO_COMMENT',
                                          'This rule has no comment', '<None>',
                                          '<None>')

        self.assertEqual(5, len(oActualSuppressionList.suppressions))
        oExpectedSuppressList.suppressions.append(oSuppression)

        for i in range(5):
            oExpected = oExpectedSuppressList.suppressions[i]
            oActual = oActualSuppressionList.suppressions[i]

            self.assertEqual(oExpected.get_warning_id(),
                             oActual.get_warning_id())
            self.assertEqual(oExpected.get_message(), oActual.get_message())
            self.assertEqual(oExpected.get_author(), oActual.get_author())
            self.assertEqual(oExpected.get_comment(), oActual.get_comment())
            self.assertEqual(oExpected.get_investigate(),
                             oActual.get_investigate())
Beispiel #11
0
    def test_create_suppression_list_w_empty_dictionary(self):
        dSuppression = {}
        oActualSuppressionList = utils.create_suppression_list(dSuppression)
        oExpectedSuppressionList = suppression_list.create()

        self.assertEqual(0, len(oActualSuppressionList.suppressions))