Пример #1
0
    def testConfigUniverseGetEntityType(self):
        context = findings_lib.FileContext('')
        type_universe = entity_type_lib.EntityTypeUniverse([])
        type_universe.AddFinding(
            findings_lib.IllegalCharacterError('stuff', context))
        field_universe = field_lib.FieldUniverse([])
        field_universe.AddFinding(
            findings_lib.InconsistentFileLocationError('', context))
        subfield_universe = subfield_lib.SubfieldUniverse([])
        subfield_universe.AddFinding(
            findings_lib.CapitalizationError('Hi', context))
        state_universe = state_lib.StateUniverse([])
        connection_universe = connection_lib.ConnectionUniverse([])
        unit_universe = unit_lib.UnitUniverse([])
        config_universe = presubmit_validate_types_lib.ConfigUniverse(
            subfield_universe=subfield_universe,
            field_universe=field_universe,
            entity_type_universe=type_universe,
            state_universe=state_universe,
            connection_universe=connection_universe,
            unit_universe=unit_universe)

        entity_type = config_universe.GetEntityType('NONEXISTENT',
                                                    'NONEXISTENT')

        self.assertIsNone(entity_type)
Пример #2
0
    def testConfigUniverse(self):
        context = findings_lib.FileContext('')
        type_universe = entity_type_lib.EntityTypeUniverse([])
        type_universe.AddFinding(
            findings_lib.IllegalCharacterError('stuff', context))
        field_universe = field_lib.FieldUniverse([])
        field_universe.AddFinding(
            findings_lib.InconsistentFileLocationError('', context))
        subfield_universe = subfield_lib.SubfieldUniverse([])
        subfield_universe.AddFinding(
            findings_lib.CapitalizationError('Hi', context))
        state_universe = state_lib.StateUniverse([])
        connection_universe = connection_lib.ConnectionUniverse([])
        connection_universe.AddFinding(
            findings_lib.InvalidConnectionNamespaceError('notglobal', context))
        unit_universe = unit_lib.UnitUniverse([])
        config_universe = presubmit_validate_types_lib.ConfigUniverse(
            subfield_universe=subfield_universe,
            field_universe=field_universe,
            entity_type_universe=type_universe,
            state_universe=state_universe,
            connection_universe=connection_universe,
            unit_universe=unit_universe)

        findings = config_universe.GetFindings()
        self.assertLen(findings, 4)
        self.assertTrue(
            config_universe.HasFindingTypes([
                findings_lib.InconsistentFileLocationError,
                findings_lib.IllegalCharacterError,
                findings_lib.CapitalizationError,
                findings_lib.InvalidConnectionNamespaceError
            ]))
        self.assertFalse(config_universe.IsValid())