summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2016-11-15 00:12:50 +0000
committerrsiddharth <s@ricketyspace.net>2016-11-15 00:12:50 +0000
commita7408d6431db51bd068e52d74f9cc9c33fca2483 (patch)
tree9a7b4d648456a95cae63aa2530d68aaabf5d9c7b /tests
parent94624361bff34f9dbde42b21ada1226887dbe3fb (diff)
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 (limited to 'tests')
-rw-r--r--tests/files/small-parkes-pkgs.list2
-rw-r--r--tests/test_gd_diff.py25
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/files/small-parkes-pkgs.list b/tests/files/small-parkes-pkgs.list
index a1980d5..d2b181f 100644
--- 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
index 33ce492..b736632 100644
--- 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)):