combox

split and encrypted files between online file storage providers
git clone git://git.ricketyspace.net/combox.git
Log | Files | Refs

commit 925ef98b9b63c2c4dbdb82bbf70d8db9e8f546f2
parent 8f3f8efa3089d53320cb6e3aaf44c7c4867ccd23
Author: Siddharth Ravikumar <sravik@bgsu.edu>
Date:   Mon,  9 Feb 2015 10:35:44 -0500

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:
tests/config_test.py | 51+++++++++++++++++++++++++++------------------------
1 file changed, 27 insertions(+), 24 deletions(-)

diff --git 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