summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gd_diff.py9
-rw-r--r--tests/test_gd_diff.py24
2 files changed, 33 insertions, 0 deletions
diff --git a/gd_diff.py b/gd_diff.py
index ef0c070..fccc557 100644
--- a/gd_diff.py
+++ b/gd_diff.py
@@ -217,3 +217,12 @@ def config_dir():
def config_file():
return os.path.join(config_dir(), 'config')
+
+
+def configured_p():
+ """Returns True if gns-deb-diff is configured; False otherwise.
+ """
+ if os.path.isfile(config_file()):
+ return True
+ else:
+ return False
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index 1b54f32..e59db1a 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -246,6 +246,30 @@ class TestGdDiff(object):
'gns-deb-diff', 'config'))
+ def test_configured_p_no(self):
+ def env(e):
+ return self.test_home
+
+ with mock.patch('os.getenv', new=env):
+ configured = configured_p()
+ assert_equal(configured, False)
+
+
+ def test_configured_p_yes(self):
+ def env(e):
+ return self.test_home
+
+ with mock.patch('os.getenv', new=env):
+ c_path = config_dir()
+ c_file = config_file()
+
+ os.makedirs(c_path)
+ open(c_file, 'w').close()
+
+ configured = configured_p()
+ assert_equal(configured, True)
+
+
def teardown(self):
"""Teardown method for this class."""
if(path.exists(self.gns_pkgs_dir)):