summaryrefslogtreecommitdiffstats
path: root/tests/config_test.py
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-01-12 21:56:48 -0500
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-01-12 21:56:48 -0500
commit5e2f2be1dd75411c52016769c0ccac2ef7db7286 (patch)
treef72b4780d00824bac133ef3e4deb0537d66bf7e7 /tests/config_test.py
parent50b626d226a510bc2888dd6eba97b461025756e2 (diff)
Added `nose' for combox/config.py, combox/crypto.py, combox/file.py
new file: tests/config_test.py new file: tests/crypto_test.py new file: tests/file_test.py
Diffstat (limited to 'tests/config_test.py')
-rw-r--r--tests/config_test.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/config_test.py b/tests/config_test.py
new file mode 100644
index 0000000..7bc50c2
--- /dev/null
+++ b/tests/config_test.py
@@ -0,0 +1,58 @@
+# Copyright (C) 2014 Combox author(s). See AUTHORS.
+#
+# This file is part of Combox.
+#
+# Combox is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Combox is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Combox (see COPYING). If not, see
+# <http://www.gnu.org/licenses/>.
+
+import yaml
+
+from nose.tools import *
+from os import path, remove, rmdir
+
+from combox.config import (config_cb, get_secret, get_stdin)
+
+
+CONFIG_DIR = path.join('tests', 'files', 'config')
+
+# sample config info.
+CONFIG_INFO = [CONFIG_DIR, '2',
+ 'gdrive', 'gdrive/path', '1024',
+ 'dbox', 'dbox/path', '1024']
+
+CONFIG_INFO_ITER = iter(CONFIG_INFO)
+
+def config_iter(dummy):
+ "Iterates through CONFIG_INFO"
+ return next(CONFIG_INFO_ITER)
+
+def test_config():
+ "Tests the combox's config function."
+
+ config_dir = CONFIG_DIR
+ pass_func = lambda: 'topsecret'
+ input_func = config_iter
+
+ 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)
+
+ # remove config dir
+ remove(config_file)
+ rmdir(CONFIG_DIR)