summaryrefslogtreecommitdiff
path: root/test/test_cerbero_build_recipe.py
diff options
context:
space:
mode:
authorAndoni Morales Alastruey <ylatuya@gmail.com>2012-04-19 20:59:38 +0200
committerAndoni Morales Alastruey <ylatuya@gmail.com>2012-04-20 12:22:38 +0200
commitacfbb39f7250b7bb00ad17340e09a3e6b94d1c8a (patch)
treec1af8fa0cc5aa73889ff14db98f35c9a6ac1bb41 /test/test_cerbero_build_recipe.py
parent9525d11fabe9cbfc2752acb23ee9bda2460c599c (diff)
Move tests to the 'test' folder
Diffstat (limited to 'test/test_cerbero_build_recipe.py')
-rw-r--r--test/test_cerbero_build_recipe.py115
1 files changed, 115 insertions, 0 deletions
diff --git a/test/test_cerbero_build_recipe.py b/test/test_cerbero_build_recipe.py
new file mode 100644
index 00000000..73c518d7
--- /dev/null
+++ b/test/test_cerbero_build_recipe.py
@@ -0,0 +1,115 @@
+# 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 os
+
+from cerbero.build import recipe
+from cerbero.config import Platform
+from test.test_common import DummyConfig
+
+
+class Class1(object):
+
+ test = None
+
+ def __init__(self):
+ self.test = 'CODEPASS'
+
+ class1_method = lambda x: None
+ compile = lambda x: 'CODEPASS'
+
+
+class Class2(object):
+
+ class2_method = lambda x: None
+ fetch = lambda x: 'CODEPASS'
+
+
+class RecipeTest(recipe.Recipe):
+
+ btype = Class1
+ stype = Class2
+
+ name = 'recipe'
+ version = '0.0.0'
+ deps = ['dep1', 'dep2']
+ platform_deps = {Platform.LINUX: ['dep3'], Platform.WINDOWS: ['dep4']}
+ post_install = lambda x: 'CODEPASS'
+
+
+class TestReceiptMetaClass(unittest.TestCase):
+
+ def setUp(self):
+ self.config = DummyConfig()
+ self.config.local_sources = ''
+ self.config.sources = ''
+ self.t = RecipeTest(self.config)
+
+ def testReceiptBases(self):
+ r = recipe.Recipe(self.config)
+ bases = r.__class__.mro()
+ self.assertTrue(Class1 not in bases)
+ self.assertTrue(Class2 not in bases)
+
+ def testReceiptSubclassBases(self):
+ bases = self.t.__class__.mro()
+ self.assertTrue(Class1 in bases)
+ self.assertTrue(Class2 in bases)
+
+ def testFunctions(self):
+ self.assertTrue(hasattr(self.t, 'class1_method'))
+ self.assertTrue(hasattr(self.t, 'class2_method'))
+ self.assertEquals(self.t.fetch(), 'CODEPASS')
+ self.assertEquals(self.t.compile(), 'CODEPASS')
+ self.assertEquals(self.t.post_install(), 'CODEPASS')
+
+ def testSubclassesInit(self):
+ self.assertEquals(self.t.test, 'CODEPASS')
+
+
+class TestReceipt(unittest.TestCase):
+
+ def setUp(self):
+ self.config = DummyConfig()
+ self.config.local_sources = 'path1'
+ self.config.sources = 'path2'
+ self.recipe = RecipeTest(self.config)
+
+ def testSources(self):
+ repo_dir = os.path.join(self.config.local_sources, self.recipe.package_name)
+ repo_dir = os.path.abspath(repo_dir)
+ build_dir = os.path.join(self.config.sources, self.recipe.package_name)
+ build_dir = os.path.abspath(build_dir)
+
+ self.assertEquals(self.recipe.repo_dir, repo_dir)
+ self.assertEquals(self.recipe.build_dir, build_dir)
+
+ def testListDeps(self):
+ self.recipe.config.target_platform = Platform.LINUX
+ self.assertEquals(['dep1', 'dep2', 'dep3'], self.recipe.list_deps())
+ self.recipe.config.target_platform = Platform.WINDOWS
+ self.assertEquals(['dep1', 'dep2', 'dep4'], self.recipe.list_deps())
+
+ def testRemoveSteps(self):
+ self.recipe._remove_steps(['donotexits'])
+ self.assertTrue(recipe.BuildSteps.FETCH in self.recipe._steps)
+ self.recipe._remove_steps([recipe.BuildSteps.FETCH])
+ self.assertTrue(recipe.BuildSteps.FETCH not in self.recipe._steps)
+ r = RecipeTest(self.config)
+ self.assertTrue(recipe.BuildSteps.FETCH in r._steps)