gns-deb-diff

automate the documentation of the differences between gNewSense and Debian.
git clone git://git.ricketyspace.net/gns-deb-diff.git
Log | Files | Refs

commit e4dd3db7afd52ff7de7acd128195decedf465f23
parent ba6981811e863e9929db87533a88b8ead52f9369
Author: rsiddharth <s@ricketyspace.net>
Date:   Sun, 13 Nov 2016 01:20:43 +0000

Add `pkgs_dir` function.

* gd_diff.py (pkgs_dir): New function.
* tests/test_gd_diff.py (test_pkgs_dir): Test for `pkgs_dir`.

Diffstat:
gd_diff.py | 12++++++++++++
tests/test_gd_diff.py | 11+++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

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