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 ba67ddb69f46b3bc2c22ca54c264a9330387efed
parent 7ee55f0fea34fdabf60ebf5161fafd7b440465f0
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue, 15 Nov 2016 23:39:59 +0000

Add function `construct_table_row`.

* gd_diff.py (construct_table_row): New function.
(bzr_pkg_readme_fmt): New global variable.
* tests/test_gd_diff.py (test_construct_table_row): Test for
  `construct_table_row`.

Diffstat:
gd_diff.py | 16++++++++++++++++
tests/test_gd_diff.py | 33+++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -30,6 +30,7 @@ field_list = [ # bzr bzr_base_url = 'bzr://bzr.savannah.gnu.org/gnewsense/' +bzr_pkg_readme_fmt = 'http://bzr.savannah.gnu.org/lh/gnewsense/packages-parkes/{}/annotate/head:/debian/README.gNewSense' readme_url_fmt = '%s/packages-{}/{}/debian/README.gNewSense' % bzr_base_url @@ -349,3 +350,18 @@ def get_wiki_page_data(release): table_data[pkg] = slurp_fields_from_readme(readme_content) return pkgs_noreadmes, table_data + + +def construct_table_row(pkg, change, reason): + """Return a table row in moinmoin wiki markup. + + """ + if change is None: + change = ' ' + if reason is None: + reason = ' ' + + more_info_link = bzr_pkg_readme_fmt.format(pkg) + + return '||{}||{}||{}||[[{}|more_info]]'.format(pkg, change, reason, + more_info_link) diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -375,6 +375,39 @@ class TestGdDiff(object): assert (type(value) == str or value is None) + def test_construct_table_row(self): + row = construct_table_row('antlr', 'Modified', + 'Removed example with non-free files') + columns = row.split('||')[1:] + assert_equal(columns[0], 'antlr') + assert_equal(columns[1], 'Modified') + assert_equal(columns[2], 'Removed example with non-free files') + assert_equal(columns[3] , '[[http://bzr.savannah.gnu.org/lh/gnewsense/packages-parkes/antlr/annotate/head:/debian/README.gNewSense|more_info]]') + + row = construct_table_row('antlr', None, + 'Removed example with non-free files') + columns = row.split('||')[1:] + assert_equal(columns[0], 'antlr') + assert_equal(columns[1], ' ') + assert_equal(columns[2], 'Removed example with non-free files') + assert_equal(columns[3] , '[[http://bzr.savannah.gnu.org/lh/gnewsense/packages-parkes/antlr/annotate/head:/debian/README.gNewSense|more_info]]') + + row = construct_table_row('antlr', 'Modified', + None) + columns = row.split('||')[1:] + assert_equal(columns[0], 'antlr') + assert_equal(columns[1], 'Modified') + assert_equal(columns[2], ' ') + assert_equal(columns[3] , '[[http://bzr.savannah.gnu.org/lh/gnewsense/packages-parkes/antlr/annotate/head:/debian/README.gNewSense|more_info]]') + + row = construct_table_row('antlr', None, + None) + columns = row.split('||')[1:] + assert_equal(columns[0], 'antlr') + assert_equal(columns[1], ' ') + assert_equal(columns[2], ' ') + assert_equal(columns[3] , '[[http://bzr.savannah.gnu.org/lh/gnewsense/packages-parkes/antlr/annotate/head:/debian/README.gNewSense|more_info]]') + def teardown(self): """Teardown method for this class."""