summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2012-06-13 12:43:18 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2012-06-19 15:50:34 +0200
commitbfa03fb79dbac6eadc9f42fd8bbd489950a89ecd (patch)
treeda4f54bae7fb5ee98dee0d3e2355e2f2a5de02ba /test
parent2abcd00b968bb0ab7d55c40536a902b172c7d745 (diff)
info_plist: add support for applications Info.plist and add unit tests
Diffstat (limited to 'test')
-rw-r--r--test/test_cerbero_packages_osx_info_plist.py81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/test_cerbero_packages_osx_info_plist.py b/test/test_cerbero_packages_osx_info_plist.py
new file mode 100644
index 00000000..7dfb1f65
--- /dev/null
+++ b/test/test_cerbero_packages_osx_info_plist.py
@@ -0,0 +1,81 @@
+# cerbero - a multi-platform build system for Open Source software
+# Copyright (C) 2012 Andoni Morales Alastruey <ylatuya@gmail.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import unittest
+import tempfile
+
+from cerbero.packages.osx.info_plist import InfoPlist, FrameworkPlist,\
+ ApplicationPlist, INFO_PLIST_TPL
+
+
+class InfoPlistTest(unittest.TestCase):
+
+ PROPS_TPL = ('%(icon)s<key>CFBundleIdentifier</key>\n'
+ '<string>test.org</string>\n'
+ '<key>CFBundleName</key>\n'
+ '<string>test</string>\n'
+ '<key>CFBundlePackageGetInfoString</key>\n'
+ '<string>Test package</string>\n'
+ '<key>CFBundlePackageType</key>\n'
+ '<string>%(ptype)s</string>\n'
+ '<key>CFBundleVersion</key>\n'
+ '<string>1.0</string>')
+
+ def setUp(self):
+ self.info_plist = InfoPlist('test', 'test.org', '1.0',
+ 'Test package')
+
+ def testFormatProperty(self):
+ self.assertEquals('<key>Key</key>\n<string>Value</string>',
+ self.info_plist.format_property('Key', 'Value'))
+
+ def testGetPropertiesString(self):
+ result = self.info_plist.get_properties_string()
+ expected = self.PROPS_TPL % {'icon': '', 'ptype': ''}
+ self.assertEquals(result, expected)
+
+ def testFrameworkPackageType(self):
+ self.info_plist = FrameworkPlist('test', 'test.org', '1.0',
+ 'Test package')
+ result = self.info_plist.get_properties_string()
+ expected = self.PROPS_TPL % {'ptype': 'FMWK', 'icon': ''}
+ self.assertEquals(result, expected)
+
+ def testApplicationPackageType(self):
+ self.info_plist = ApplicationPlist('test', 'test.org', '1.0',
+ 'Test package')
+ result = self.info_plist.get_properties_string()
+ expected = self.PROPS_TPL % {'ptype': 'APPL', 'icon': ''}
+ self.assertEquals(result, expected)
+
+ def testGetPropertiesStringWithIcon(self):
+ self.info_plist.icon = 'test.ico'
+ result = self.info_plist.get_properties_string()
+ expected = self.PROPS_TPL % {'ptype': '', 'icon':
+ self.info_plist.format_property('CFBundleIconFile', 'test.ico') +
+ '\n'}
+ self.info_plist.icon = None
+ self.assertEquals(result, expected)
+
+ def testSave(self):
+ tmp = tempfile.NamedTemporaryFile()
+ self.info_plist.save(tmp.name)
+ with open(tmp.name, 'r') as f:
+ result = f.read()
+ expected = INFO_PLIST_TPL % self.info_plist.get_properties_string()
+ self.assertEquals(result, expected)