summaryrefslogtreecommitdiffstats
path: root/tests/config_test.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-02-09 10:35:44 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-02-09 10:35:44 -0500
commit925ef98b9b63c2c4dbdb82bbf70d8db9e8f546f2 (patch)
tree79a5d5d934b517c327f0c778db8637c1282071f8 /tests/config_test.py
parent8f3f8efa3089d53320cb6e3aaf44c7c4867ccd23 (diff)
tests/config_test.py: re-wrote it.
Now the test is in a Test class with proper setup and teardown methods. The teardown method has been purposely not fleshed out. It will be fleshed out after all the test modules have been re-written.
Diffstat (limited to 'tests/config_test.py')
-rw-r--r--tests/config_test.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/tests/config_test.py b/tests/config_test.py
index 95dedd8..b9cfb81 100644
--- a/tests/config_test.py
+++ b/tests/config_test.py
@@ -22,37 +22,40 @@ from nose.tools import *
from os import path, remove, rmdir
from combox.config import (config_cb, get_secret, get_stdin)
+from tests.utils import get_input_func
+class TestConfig(object):
+ """
+ Class that tests the config.py module.
+ """
-CONFIG_DIR = path.join('tests', 'test-config')
-combox_dir = path.join('tests', 'files')
-node_dir_0 = path.join('tests', 'shard-dir-0')
-node_dir_1 = path.join('tests', 'shard-dir-1')
+ @classmethod
+ def setup_class(self):
+ """Set things up."""
+ self.CONFIG_DIR = path.join('tests', 'test-config')
-# sample config info.
-CONFIG_INFO = ['testbox', combox_dir, CONFIG_DIR, '2',
- 'node-0', node_dir_0, '1024',
- 'node-1', node_dir_1, '1024']
-CONFIG_INFO_ITER = iter(CONFIG_INFO)
+ def test_config(self):
+ "Tests the combox's config function."
-def config_iter(dummy):
- "Iterates through CONFIG_INFO"
- return next(CONFIG_INFO_ITER)
+ config_dir = self.CONFIG_DIR
+ pass_func = lambda: 'topsecret'
+ input_func = get_input_func()
-def test_config():
- "Tests the combox's config function."
+ config_cb(config_dir, pass_func, input_func)
- config_dir = CONFIG_DIR
- pass_func = lambda: 'topsecret'
- input_func = config_iter
+ # check if the config yaml file is valid
+ config_file = path.join(config_dir, 'config.yaml')
+ try:
+ config = yaml.load(file(config_file, 'r'))
+ print "config: ", config
+ except yaml.YAMLError, exc:
+ raise AssertionError("Error in configuration file:", exc)
- config_cb(config_dir, pass_func, input_func)
- # check if the config yaml file is valid
- config_file = path.join(CONFIG_DIR, 'config.yaml')
- try:
- config = yaml.load(file(config_file, 'r'))
- except yaml.YAMLError, exc:
- raise AssertionError("Error in configuration file:", exc)
+ @classmethod
+ def teardown_class(self):
+ """Tear everything down."""
+ # must delete the created config.yaml
+ pass