summaryrefslogtreecommitdiffstats
path: root/python/macholib/macholib_tests/test_framework.py
blob: 8c123afd00f33c6d0adba1c564465da2226cd2e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from macholib import framework

import sys
if sys.version_info[:2] <= (2,6):
    import unittest2 as unittest
else:
    import unittest


class TestFramework (unittest.TestCase):
    def test_framework(self):
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Versions/SomeVersion/Name_Suffix'),
                dict(
                    location='Location',
                    name='Name.framework/Versions/SomeVersion/Name_Suffix',
                    shortname='Name',
                    version='SomeVersion',
                    suffix='Suffix',
                ))
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Versions/SomeVersion/Name'),
                dict(
                    location='Location',
                    name='Name.framework/Versions/SomeVersion/Name',
                    shortname='Name',
                    version='SomeVersion',
                    suffix=None,
                ))
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Name_Suffix'),
                dict(
                    location='Location',
                    name='Name.framework/Name_Suffix',
                    shortname='Name',
                    version=None,
                    suffix='Suffix',
                ))
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Name'),
                dict(
                    location='Location',
                    name='Name.framework/Name',
                    shortname='Name',
                    version=None,
                    suffix=None
                ))
        self.assertEqual(
                framework.framework_info('Location/Name.framework.disabled/Name'),
                None
                )
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Versions/A/B/Name'),
                None
                )
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Versions/A'),
                None
                )
        self.assertEqual(
                framework.framework_info('Location/Name.framework/Versions/A/Name/_debug'),
                None
                )

    def test_interal_tests(self):
        # Ported over from the source file
        def d(location=None, name=None, shortname=None, version=None, suffix=None):
            return dict(
                location=location,
                name=name,
                shortname=shortname,
                version=version,
                suffix=suffix
            )
        self.assertEqual(framework.framework_info('completely/invalid'), None)
        self.assertEqual(framework.framework_info('completely/invalid/_debug'), None)
        self.assertEqual(framework.framework_info('P/F.framework'), None)
        self.assertEqual(framework.framework_info('P/F.framework/_debug'), None)
        self.assertEqual(framework.framework_info('P/F.framework/F'), d('P', 'F.framework/F', 'F'))
        self.assertEqual(framework.framework_info('P/F.framework/F_debug'), d('P', 'F.framework/F_debug', 'F', suffix='debug'))
        self.assertEqual(framework.framework_info('P/F.framework/Versions'), None)
        self.assertEqual(framework.framework_info('P/F.framework/Versions/A'), None)
        self.assertEqual(framework.framework_info('P/F.framework/Versions/A/F'), d('P', 'F.framework/Versions/A/F', 'F', 'A'))
        self.assertEqual(framework.framework_info('P/F.framework/Versions/A/F_debug'), d('P', 'F.framework/Versions/A/F_debug', 'F', 'A', 'debug'))


if __name__ == "__main__":
    unittest.main()