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 a7408d6431db51bd068e52d74f9cc9c33fca2483
parent 94624361bff34f9dbde42b21ada1226887dbe3fb
Author: rsiddharth <s@ricketyspace.net>
Date:   Tue, 15 Nov 2016 00:12:50 +0000

Add `get_wiki_page_data` function.

* gd_diff.py (get_wiki_page_data): New functions.
* tests/files/small-parkes-pkgs.list: Update file
* tests/test_gd_diff.py (test_get_wiki_page_data): Add test for
`get_wiki_page_data` function.

Diffstat:
gd_diff.py | 21+++++++++++++++++++++
tests/files/small-parkes-pkgs.list | 2+-
tests/test_gd_diff.py | 25+++++++++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/gd_diff.py b/gd_diff.py @@ -328,3 +328,24 @@ def slurp_fields_from_readme(content): field_values[field] = None return field_values + + +def get_wiki_page_data(release): + """Returns data needed to generate the gNewSense Debian Diff table. + + """ + # get packages for release. + pkgs_file = mk_pkgs_list(release) + pkgs = read_packages(pkgs_file) + + # get readmes for release. + pkgs_noreadmes = slurp_all_gns_readmes(release, pkgs) + + # go through each pkg's readme and slurp the fields. + table_data = {} + for pkg in pkgs: + readme_content = read_gns_readme(release, pkg) + if readme_content: + table_data[pkg] = slurp_fields_from_readme(readme_content) + + return pkgs_noreadmes, table_data diff --git a/tests/files/small-parkes-pkgs.list b/tests/files/small-parkes-pkgs.list @@ -14,6 +14,6 @@ doc-linux doc-linux-hr doc-linux-it doc-linux-ja - another-pkgs-no-readme + another-pkg-no-readme doc-linux-pl enscript \ No newline at end of file diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -12,6 +12,8 @@ import os import subprocess import sys +import gd_diff + from io import StringIO from os import path from shutil import rmtree @@ -351,6 +353,29 @@ class TestGdDiff(object): 'Removed example with non-free files.') + def test_get_wiki_page_data(self): + def mock_mk_pkgs_list(r): + return self.small_pkgs_file + + pkgs = [p.strip() + for p in open(self.small_pkgs_file, 'r').read() \ + .split('\n')] + + with mock.patch('os.getenv', new=self.env_func), \ + mock.patch('gd_diff.mk_pkgs_list', new=mock_mk_pkgs_list): + pkgs_noreadmes, table_data = get_wiki_page_data('parkes') + + for pkg in pkgs_noreadmes: + assert pkg in ['pkg-with-no-readme', 'another-pkg-no-readme'] + + for pkg, field_values in table_data.items(): + assert pkg in pkgs + for field, value in field_values.items(): + assert field in gd_diff.field_list + assert (type(value) == str or + value is None) + + def teardown(self): """Teardown method for this class.""" if(path.exists(self.gns_pkgs_dir)):