aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-27 20:59:26 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-05-27 20:59:26 -0300
commitc822ec02f43b0549b689a0f0dc31486c7f5539a5 (patch)
treebf32c3f42e950c02b7edd96d2ef329d53fa9f508 /tests/test_config.py
parentmoved the snippet of code that creates a "fake" DESCRIPTION tree from tests/t... (diff)
downloadg-octave-c822ec02f43b0549b689a0f0dc31486c7f5539a5.tar.gz
g-octave-c822ec02f43b0549b689a0f0dc31486c7f5539a5.tar.bz2
g-octave-c822ec02f43b0549b689a0f0dc31486c7f5539a5.zip
Added tests to g_octave/config.py (tests/test_config.py)
Diffstat (limited to 'tests/test_config.py')
-rw-r--r--tests/test_config.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test_config.py b/tests/test_config.py
new file mode 100644
index 0000000..7c2cc26
--- /dev/null
+++ b/tests/test_config.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+ test_config.py
+ ~~~~~~~~~~~~~~
+
+ test suite for the *g_octave.config* module
+
+ :copyright: (c) 2010 by Rafael Goncalves Martins
+ :license: GPL-2, see LICENSE for more details.
+"""
+
+import os
+import unittest
+
+from g_octave import config
+
+
+class TestConfig(unittest.TestCase):
+
+ def setUp(self):
+ # TODO: fetch_phase = False
+ current_dir = os.path.dirname(os.path.abspath(__file__))
+
+ # object with the config file empty, should use the default values
+ self._empty_cfg = config.Config(
+ config_file = os.path.join(current_dir, 'g-octave_empty.cfg'),
+ create_dirs = False,
+ fetch_phase = True
+ )
+
+ # object with an example config file
+ self._cfg = config.Config(
+ config_file = os.path.join(current_dir, 'g-octave.cfg'),
+ create_dirs = False,
+ fetch_phase = True
+ )
+
+ def test_empty_config_attributes(self):
+ self.assertEqual(self._empty_cfg.db, '/var/cache/g-octave')
+ self.assertEqual(self._empty_cfg.overlay, '/usr/local/portage/g-octave')
+ self.assertEqual(self._empty_cfg.categories, 'main,extra,language')
+ self.assertEqual(self._empty_cfg.db_mirror, 'http://files.rafaelmartins.eng.br/octave-forge')
+
+ def test_config_attributes(self):
+ self.assertEqual(self._cfg.db, '/path/to/the/db')
+ self.assertEqual(self._cfg.overlay, '/path/to/the/overlay')
+ self.assertEqual(self._cfg.categories, 'comma,separated,categories,names')
+ self.assertEqual(self._cfg.db_mirror, 'http://some.cool.url/octave-forge/')
+
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(TestConfig('test_empty_config_attributes'))
+ suite.addTest(TestConfig('test_config_attributes'))
+ return suite