summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-11-13 18:33:03 +0000
committerrsiddharth <s@ricketyspace.net>2016-11-13 18:33:03 +0000
commitfca51ac7858705dbf11b3900d40b40bbe7145aba (patch)
treed2525f6df845ae186cb7cc1250498ed9fb106b84 /tests
parent0b80b898c84b8747fe8b8ac7b485b06f7cd1e22e (diff)
Add `configure` function.
* gd_diff.py (configure): New function. * tests/test_gd_diff.py (test_configure): Test for `configure` function.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gd_diff.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index 67d9b8d..b62e014 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -6,6 +6,7 @@
# gns-deb-diff is under the Public Domain. See
# <https://creativecommons.org/publicdomain/zero/1.0>
+import builtins
import json
import os
import subprocess
@@ -350,6 +351,27 @@ class TestGdDiff(object):
assert_equal(configured, True)
+ def test_configure(self):
+ def env(e):
+ return self.test_home
+
+ inputs = ['usrnm', 'weasaspeciesrfckd']
+ def mock_input(p):
+ return inputs.pop(0)
+
+ with mock.patch('os.getenv', new=env), \
+ mock.patch('builtins.input', new=mock_input):
+ configure()
+
+ # read config file
+ config = json.load(open(config_file(), 'r'))
+
+ # tests
+ assert_equal(config['user'], 'usrnm')
+ assert_equal(config['pass'], 'weasaspeciesrfckd')
+ assert_equal(oct(os.stat(config_file()).st_mode), '0o100600')
+
+
def teardown(self):
"""Teardown method for this class."""
if(path.exists(self.gns_pkgs_dir)):