summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-11-13 01:20:43 +0000
committerrsiddharth <s@ricketyspace.net>2016-11-13 01:20:43 +0000
commite4dd3db7afd52ff7de7acd128195decedf465f23 (patch)
treeafabf19792ed041e5147f2c82f49f1699bed7538
parentba6981811e863e9929db87533a88b8ead52f9369 (diff)
Add `pkgs_dir` function.
* gd_diff.py (pkgs_dir): New function. * tests/test_gd_diff.py (test_pkgs_dir): Test for `pkgs_dir`.
-rw-r--r--gd_diff.py12
-rw-r--r--tests/test_gd_diff.py11
2 files changed, 23 insertions, 0 deletions
diff --git a/gd_diff.py b/gd_diff.py
index 384e92f..63621a0 100644
--- a/gd_diff.py
+++ b/gd_diff.py
@@ -229,6 +229,18 @@ def config_file():
return os.path.join(config_dir(), 'config')
+def pkgs_dir():
+ """Return the `pkgs` directory.
+
+ As a side effect, the directory is created if it does not exist.
+ """
+ pd = os.path.join(config_dir(), 'pkgs')
+ if not os.path.isdir(pd):
+ os.mkdir(pd)
+
+ return pd
+
+
def configured_p():
"""Returns True if gns-deb-diff is configured; False otherwise.
"""
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index ff092a2..0130482 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -247,6 +247,17 @@ class TestGdDiff(object):
'gns-deb-diff', 'config'))
+ def test_pkgs_dir(self):
+ def env(e):
+ return self.test_home
+
+ with mock.patch('os.getenv', new=env):
+ pd = pkgs_dir()
+ assert_equal(pd, os.path.join(self.test_home, '.config',
+ 'gns-deb-diff', 'pkgs'))
+ assert_equal(os.path.isdir(pd), True)
+
+
def test_configured_p_no(self):
def env(e):
return self.test_home