Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 */"))
def testGetItem(self):
dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
self.assertIsNotNone(dobj['1'])
self.assertIsNone(dobj['4'])
def testGetKeys(self):
dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
keys = dobj.get_keys()
self.assertListEqual(keys, ['1', '2', '3'])
def testContains(self):
dobj = objects().parse(PBXObjectTest.MINIMUM_OBJ)
self.assertTrue('1' in dobj)
self.assertFalse('4' in dobj)
def testParseCreateObjectOfRightTypes(self):
obj = {"objects": {"id": {"isa": "type"}}}
dobj = PBXGenericObject().parse(obj)
self.assertIsInstance(dobj.objects, objects)
def testParseNonObject(self):
obj = [1, 2, 3]
dobj = objects().parse(obj)
self.assertIsInstance(dobj, list)
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']))
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)
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'), [])
def __init__(self, parent=None):
super(objects, self).__init__(parent)
# sections: dict
# sections get aggregated under the isa type. Each contains a list of tuples (id, obj) with every object defined
self._sections = {}