aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-29 23:50:31 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-29 23:50:31 -0300
commit54a332d930eb69fc0e313fcc3033df2680b32b6c (patch)
tree256dcc4cc229199be4e78c971f6746ccb19fc15b
parentadded sample ebuilds to help the tests/test_ebuild.py test suite (diff)
downloadg-octave-54a332d930eb69fc0e313fcc3033df2680b32b6c.tar.gz
g-octave-54a332d930eb69fc0e313fcc3033df2680b32b6c.tar.bz2
g-octave-54a332d930eb69fc0e313fcc3033df2680b32b6c.zip
finished tests/test_ebuild.py; fixed tests/test_description.py and tests/utils.py
-rw-r--r--tests/test_description.py10
-rw-r--r--tests/test_ebuild.py46
-rw-r--r--tests/utils.py4
3 files changed, 52 insertions, 8 deletions
diff --git a/tests/test_description.py b/tests/test_description.py
index c7042e6..85bc327 100644
--- a/tests/test_description.py
+++ b/tests/test_description.py
@@ -183,10 +183,12 @@ class TestDescription(unittest.TestCase):
self.assertEqual(self.desc.categories, 'Category1,Category2, Category3')
self.assertEqual(self.desc.url, 'http://example.org')
- # the requirements can't be tested because the test system can't
- # check the non-octave packages yet.
- self.assertEqual(self.desc.systemrequirements, [])
- self.assertEqual(self.desc.buildrequires, [])
+ self.assertEqual(self.desc.systemrequirements, [
+ '>=g-octave/pkg1-4.3.2',
+ '<g-octave/pkg2-1.2.3',
+ 'g-octave/pkg3'
+ ])
+ self.assertEqual(self.desc.buildrequires, ['>g-octave/pkg4-1.0.0'])
self.assertEqual(self.desc.depends, ['>=sci-mathematics/octave-3.0.0'])
self.assertEqual(self.desc.autoload, 'NO')
diff --git a/tests/test_ebuild.py b/tests/test_ebuild.py
index 5e0c629..580e2a3 100644
--- a/tests/test_ebuild.py
+++ b/tests/test_ebuild.py
@@ -11,16 +11,18 @@
:license: GPL-2, see LICENSE for more details.
"""
+import os
import unittest
import utils
-from g_octave import ebuild
+from g_octave import ebuild, overlay
class TestEbuild(unittest.TestCase):
def setUp(self):
- self._config, self._config_file, self._dir = utils.create_env()
+ self._config, self._config_file, self._dir = utils.create_env(json_files=True)
+ overlay.create_overlay(conf = self._config, quiet = True)
def test_re_keywords(self):
keywords = [
@@ -47,6 +49,45 @@ class TestEbuild(unittest.TestCase):
kwtpl
)
+ def test_generated_ebuilds(self):
+ ebuilds = [
+ ('main1', '0.0.1'),
+ ('main2', '0.0.1'),
+ ('extra1', '0.0.1'),
+ ('extra2', '0.0.1'),
+ ('language1', '0.0.1'),
+ ('language2', '0.0.1'),
+ ]
+ for pkgname, pkgver in ebuilds:
+ _ebuild = ebuild.Ebuild(
+ pkgname + '-' + pkgver,
+ conf = self._config,
+ )
+ _ebuild.create(
+ accept_keywords = 'amd64 ~amd64 x86 ~x86',
+ manifest = False,
+ display_info = False
+ )
+ created_ebuild_file = os.path.join(
+ self._config.overlay,
+ 'g-octave', pkgname,
+ pkgname + '-' + pkgver + '.ebuild'
+ )
+ original_ebuild_file = os.path.join(
+ os.path.dirname(os.path.abspath(__file__)),
+ 'files', 'ebuilds',
+ pkgname + '-' + pkgver + '.ebuild'
+ )
+
+ # compare ebuilds, line by line
+ with open(created_ebuild_file) as fp:
+ created_ebuild = fp.readlines()
+ with open(original_ebuild_file) as fp:
+ original_ebuild = fp.readlines()
+ self.assertEqual(len(created_ebuild), len(original_ebuild))
+ for i in range(len(created_ebuild)):
+ self.assertEqual(created_ebuild[i], original_ebuild[i])
+
def tearDown(self):
utils.clean_env(self._config_file, self._dir)
@@ -54,4 +95,5 @@ class TestEbuild(unittest.TestCase):
def suite():
suite = unittest.TestSuite()
suite.addTest(TestEbuild('test_re_keywords'))
+ suite.addTest(TestEbuild('test_generated_ebuilds'))
return suite
diff --git a/tests/utils.py b/tests/utils.py
index 6288333..1192573 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -18,7 +18,7 @@ import tempfile
from g_octave import config
-def create_env():
+def create_env(json_files=False):
"""returns a tuple with the *g_octave.config* object and the path of
the temporary config and directory
"""
@@ -38,7 +38,7 @@ def create_env():
cp.write(fp)
conf = config.Config(
- fetch_phase = True,
+ fetch_phase = not json_files,
config_file = config_file,
create_dirs = True
)