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 43b60847ab573c449a52aaed497c378ce8f2262c
parent 88eaf52a52f0014aa70b1c693e32922b42704561
Author: rsiddharth <s@ricketyspace.net>
Date:   Thu, 26 Jan 2017 04:34:51 +0000

Flesh out `make_push` function.

* gd_diff.py (make_push): Update function.
(gns_wiki): Add global variable; holds gNewSense wiki URL.
* tests/test_gd_diff.py (test_make_push): Add test method for
`make_push` function.

Diffstat:
gd_diff.py | 17+++++++++++++++--
tests/test_gd_diff.py | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -35,6 +35,7 @@ field_list = [ # urls sv_bzr_http = 'http://bzr.savannah.gnu.org' sv_bzr_gns = '/'.join(['bzr://bzr.savannah.gnu.org', 'gnewsense']) +gns_wiki = 'http://gnewsense.org' # fmt readme_link_fmt = '/'.join([sv_bzr_http, 'lh', 'gnewsense', @@ -475,16 +476,28 @@ def make_push(args): """ release = args.release version = args.version + + # read previously generated wiki page for release + old_wiki_page = read_wiki_page(release) + + # freshly generate wiki page pkgs_noreadmes, wiki_page = generate_wiki_page(release) + if old_wiki_page == wiki_page: + print('no changes.') + return + + # configure if needed. if not configured_p(): configure() + # read configuration. config = read_config_file() - # write_wiki_page(release, content) - # push_wiki_page(url, config['user'], config[pass'], verion, wiki_page) + write_wiki_page(release, wiki_page) + push_wiki_page(gns_wiki, config['user'], config['pass'], version, wiki_page) + return config, pkgs_noreadmes, old_wiki_page, wiki_page def get_args(): diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -537,6 +537,60 @@ class TestGdDiff(object): assert barfs == expected_barfs + def test_make_push(self): + # mock args + mock_sys_argv = ['gd-diff', 'parkes', '3'] + + # mock `read_wiki_page` function + expected_old_wiki_page = 'wiki content old content.' + def mock_rwp(r): + return expected_old_wiki_page + + # mock `generate_wiki_page` function + expected_wiki_page = 'wiki content.' + expected_pkgs_noreadmes = ['noreadmepkg'] + def mock_gwg(r): + return expected_pkgs_noreadmes, expected_wiki_page + + # mock `configured_p` function + def mock_cp(): + return False + + # mock `configure` function + def mock_c(): + return + + # mock `read_config_file` + expected_config = {'user': 'usrnm', 'pass': 'weasaspeciesrfckd'} + def mock_rcf(): + return expected_config + + # mock `write_wiki_page` + def mock_wwp(r, wp): + return + + # mock `push_wiki_page` + def mock_pwp(u, usr, p, v, wp): + return + + with mock.patch('os.getenv', new=self.env_func), \ + mock.patch('gd_diff.read_wiki_page', new=mock_rwp), \ + mock.patch('gd_diff.generate_wiki_page', new=mock_gwg), \ + mock.patch('gd_diff.configured_p', new=mock_cp), \ + mock.patch('gd_diff.configure', new=mock_c), \ + mock.patch('gd_diff.read_config_file', new=mock_rcf), \ + mock.patch('gd_diff.write_wiki_page', new=mock_wwp), \ + mock.patch('gd_diff.push_wiki_page', new=mock_pwp), \ + mock.patch('sys.argv', new=mock_sys_argv): + args = get_args() + config, pkgs_noreadmes, old_wiki_page, wiki_page = make_push(args) + + assert expected_config == config + assert expected_pkgs_noreadmes == pkgs_noreadmes + assert expected_old_wiki_page == old_wiki_page + assert expected_wiki_page == wiki_page + + def test_get_args_gd_diff_version(self): mock_sys_argv = ['gd-diff', '--version'] with mock.patch('sys.stdout', new=StringIO()) as output, \