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 a295268af9a8df2e48c6bb772f7df876f4459883
parent ba0568d39f47233b185262b1b00bc0581d276001
Author: rsiddharth <s@ricketyspace.net>
Date:   Fri, 20 Jan 2017 05:10:45 +0000

Add `read_wiki_page` function.

* gd_diff.py (read_wiki_page): New function.
* tests/test_gd_diff.py
(test_read_wiki_page_returns_none_if_wikipage_nonexistent)
(test_read_wiki_page_returns_content_if_wikipage_existent): Tests for
  `read_wiki_page`.

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

diff --git a/gd_diff.py b/gd_diff.py @@ -405,6 +405,17 @@ def generate_wiki_page(release): return pkgs_noreadmes, wiki_page +def read_wiki_page(release): + """Read wiki page for `release` from disk. + """ + wp_file = wiki_page_path(release) + + if not path.isfile(wp_file): + return None + + return read_file(wp_file) + + def write_wiki_page(release, content): """Write wiki page `content` to `release`' last.rev file. diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py @@ -477,6 +477,25 @@ class TestGdDiff(object): assert wiki_page == gns_wiki_header() + '\n' + wiki_table + def test_read_wiki_page_returns_none_if_wikipage_nonexistent(self): + with mock.patch('os.getenv', new=self.env_func): + wiki_page_content = read_wiki_page('bogus-release') + assert wiki_page_content == None + + + def test_read_wiki_page_returns_content_if_wikipage_existent(self): + with mock.patch('os.getenv', new=self.env_func): + wp_file = wiki_page_path('bogus-release') + + # write some bogus content + bogus_content = 'bogus content' + with open(wp_file, 'w') as f: + f.write(bogus_content) + + wiki_page_content = read_wiki_page('bogus-release') + assert wiki_page_content == bogus_content + + def test_push_wiki_page(self): url = 'http://localhost:8080' user = 's'