diff options
-rw-r--r-- | tests/config_test.py | 51 |
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 |