예제 #1
0
    def testGetObjectsInsection(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        sections = dobj.get_objects_in_section('phase1', 'phase2')

        self.assertSetEqual(set(sections).intersection(dobj._sections['phase1']), set(dobj._sections['phase1']))
        self.assertSetEqual(set(sections).intersection(dobj._sections['phase2']), set(dobj._sections['phase2']))
        self.assertEqual(dobj.get_objects_in_section('phaseX'), [])
예제 #2
0
    def testGetConfigurationTargets(self):
        obj = {
            '1': {'isa': 'PBXNativeTarget', 'name': 'app', 'buildConfigurationList': '3'},
            '2': {'isa': 'PBXAggregateTarget', 'name': 'report', 'buildConfigurationList': '4'},
            '3': {'isa': 'XCConfigurationList', 'buildConfigurations': ['5', '6']},
            '4': {'isa': 'XCConfigurationList', 'buildConfigurations': ['7', '8']},
            '5': {'isa': 'XCBuildConfiguration', 'name': 'Release', 'id': '5'},
            '6': {'isa': 'XCBuildConfiguration', 'name': 'Debug', 'id': '6'},
            '7': {'isa': 'XCBuildConfiguration', 'name': 'Release', 'id': '7'},
            '8': {'isa': 'XCBuildConfiguration', 'name': 'Debug', 'id': '8'},
        }
        dobj = objects().parse(obj)

        result = [x for x in dobj.get_configurations_on_targets()]
        self.assertEqual(result.__len__(), 4)
        self.assertSetEqual(set([x.id for x in result]), set(['5', '6', '7', '8']))

        result = [x for x in dobj.get_configurations_on_targets(target_name='app')]
        self.assertEqual(result.__len__(), 2)
        self.assertSetEqual(set([x.id for x in result]), set(['5', '6']))

        result = [x for x in dobj.get_configurations_on_targets(configuration_name='Release')]
        self.assertSetEqual(set([x.id for x in result]), set(['5', '7']))

        result = [x for x in dobj.get_configurations_on_targets(target_name='app', configuration_name='Release')]
        self.assertEqual(result.__len__(), 1)
        self.assertSetEqual(set([x.id for x in result]), set(['5']))
예제 #3
0
    def testPrintSeparateSections(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        string = dobj.__repr__()

        self.assertTrue(string.__contains__("/* Begin phase1 section */"))
        self.assertTrue(string.__contains__("/* End phase1 section */"))
        self.assertTrue(string.__contains__("/* Begin phase2 section */"))
        self.assertTrue(string.__contains__("/* End phase2 section */"))
예제 #4
0
    def testPrintSeparateSections(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        string = dobj.__repr__()

        self.assertTrue(string.__contains__("/* Begin phase1 section */"))
        self.assertTrue(string.__contains__("/* End phase1 section */"))
        self.assertTrue(string.__contains__("/* Begin phase2 section */"))
        self.assertTrue(string.__contains__("/* End phase2 section */"))
예제 #5
0
    def testGetObjectsInsection(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        sections = dobj.get_objects_in_section('phase1', 'phase2')

        self.assertSetEqual(
            set(sections).intersection(dobj._sections['phase1']),
            set(dobj._sections['phase1']))
        self.assertSetEqual(
            set(sections).intersection(dobj._sections['phase2']),
            set(dobj._sections['phase2']))
        self.assertEqual(dobj.get_objects_in_section('phaseX'), [])
예제 #6
0
    def testGetTargets(self):
        obj = {
            '1': {'isa': 'PBXNativeTarget', 'name': 'app'},
            '2': {'isa': 'PBXAggregatedTarget', 'name': 'report'}
        }
        dobj = objects().parse(obj)

        self.assertEqual(dobj.get_targets().__len__(), 2)
        self.assertEqual(dobj.get_targets('app').__len__(), 1)
        self.assertEqual(dobj.get_targets('report').__len__(), 1)
        self.assertEqual(dobj.get_targets('whatever').__len__(), 0)
예제 #7
0
    def testGetTargets(self):
        obj = {
            '1': {
                'isa': 'PBXNativeTarget',
                'name': 'app'
            },
            '2': {
                'isa': 'PBXAggregatedTarget',
                'name': 'report'
            }
        }
        dobj = objects().parse(obj)

        self.assertEqual(dobj.get_targets().__len__(), 2)
        self.assertEqual(dobj.get_targets('app').__len__(), 1)
        self.assertEqual(dobj.get_targets('report').__len__(), 1)
        self.assertEqual(dobj.get_targets('whatever').__len__(), 0)
예제 #8
0
    def testGetKeys(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        keys = dobj.get_keys()

        self.assertListEqual(keys, ['1', '2', '3'])
예제 #9
0
    def testParseNonObject(self):
        obj = [1, 2, 3]
        dobj = objects().parse(obj)

        self.assertIsInstance(dobj, list)
예제 #10
0
 def testContains(self):
     dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
     self.assertTrue('1' in dobj)
     self.assertFalse('4' in dobj)
예제 #11
0
    def testParseGroupsPhases(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)

        self.assertEqual(dobj._sections.__len__(), 2)
        self.assertEqual(dobj._sections['phase1'].__len__(), 2)
        self.assertEqual(dobj._sections['phase2'].__len__(), 1)
예제 #12
0
 def testGetItem(self):
     dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
     self.assertIsNotNone(dobj['1'])
     self.assertIsNone(dobj['4'])
예제 #13
0
 def testGetItem(self):
     dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
     self.assertIsNotNone(dobj['1'])
     self.assertIsNone(dobj['4'])
예제 #14
0
    def testParseGroupsPhases(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)

        self.assertEqual(dobj._sections.__len__(), 2)
        self.assertEqual(dobj._sections['phase1'].__len__(), 2)
        self.assertEqual(dobj._sections['phase2'].__len__(), 1)
예제 #15
0
    def testGetKeys(self):
        dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
        keys = dobj.get_keys()

        self.assertListEqual(keys, ['1', '2', '3'])
예제 #16
0
    def testParseNonObject(self):
        obj = [1, 2, 3]
        dobj = objects().parse(obj)

        self.assertIsInstance(dobj, list)
예제 #17
0
    def testGetConfigurationTargets(self):
        obj = {
            '1': {
                'isa': 'PBXNativeTarget',
                'name': 'app',
                'buildConfigurationList': '3'
            },
            '2': {
                'isa': 'PBXAggregateTarget',
                'name': 'report',
                'buildConfigurationList': '4'
            },
            '3': {
                'isa': 'XCConfigurationList',
                'buildConfigurations': ['5', '6']
            },
            '4': {
                'isa': 'XCConfigurationList',
                'buildConfigurations': ['7', '8']
            },
            '5': {
                'isa': 'XCBuildConfiguration',
                'name': 'Release',
                'id': '5'
            },
            '6': {
                'isa': 'XCBuildConfiguration',
                'name': 'Debug',
                'id': '6'
            },
            '7': {
                'isa': 'XCBuildConfiguration',
                'name': 'Release',
                'id': '7'
            },
            '8': {
                'isa': 'XCBuildConfiguration',
                'name': 'Debug',
                'id': '8'
            },
        }
        dobj = objects().parse(obj)

        result = [x for x in dobj.get_configurations_on_targets()]
        self.assertEqual(result.__len__(), 4)
        self.assertSetEqual(set([x.id for x in result]),
                            set(['5', '6', '7', '8']))

        result = [
            x for x in dobj.get_configurations_on_targets(target_name='app')
        ]
        self.assertEqual(result.__len__(), 2)
        self.assertSetEqual(set([x.id for x in result]), set(['5', '6']))

        result = [
            x for x in dobj.get_configurations_on_targets(
                configuration_name='Release')
        ]
        self.assertSetEqual(set([x.id for x in result]), set(['5', '7']))

        result = [
            x for x in dobj.get_configurations_on_targets(
                target_name='app', configuration_name='Release')
        ]
        self.assertEqual(result.__len__(), 1)
        self.assertSetEqual(set([x.id for x in result]), set(['5']))
예제 #18
0
 def testContains(self):
     dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
     self.assertTrue('1' in dobj)
     self.assertFalse('4' in dobj)