From 925ef98b9b63c2c4dbdb82bbf70d8db9e8f546f2 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Mon, 9 Feb 2015 10:35:44 -0500 Subject: 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. --- tests/config_test.py | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3