diff options
author | rsiddharth <s@ricketyspace.net> | 2016-11-13 16:42:54 +0000 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2016-11-13 16:42:54 +0000 |
commit | 0b80b898c84b8747fe8b8ac7b485b06f7cd1e22e (patch) | |
tree | bb50974f2734c23b7ed7e7d8a558a11266659a66 /tests | |
parent | 92b8a39ca5d48dad73c646439529e9f84a76fc78 (diff) |
Add `read_config_file` function.
* gd_diff.py (read_config_file): New function.
* tests/test_gd_diff.py (test_read_config_file_fail)
(test_read_config_file_success): Tests for read_config_file.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_gd_diff.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py index cc7fc4a..67d9b8d 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 json import os import subprocess import sys @@ -247,6 +248,28 @@ class TestGdDiff(object): 'gns-deb-diff', 'config')) + def test_read_config_file_fail(self): + config = read_config_file() + assert_equal(config, False) + + + def test_read_config_file_success(self): + def env(e): + return self.test_home + + with mock.patch('os.getenv', new=env): + c_file = config_file() + + # first write sample config file. + json.dump({'user': 'usrnm', 'pass': 'weasaspeciesrfckd'}, + open(c_file, 'w')) + + # now on to the test. + config = read_config_file() + assert_equal(config['user'], 'usrnm') + assert_equal(config['pass'], 'weasaspeciesrfckd') + + def test_pkgs_dir(self): def env(e): return self.test_home |