summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2017-01-06 03:30:03 +0000
committerrsiddharth <s@ricketyspace.net>2017-01-06 03:30:03 +0000
commitd35105f158819f0f731a4efc7e138905ef8e627d (patch)
tree43f5d6cf8cd851dd5c8657eda7c3e8b56517fb8a /tests
parente46931f435cf00f1d70a6a6ccb755b92b7eff441 (diff)
Add `push_wiki_page` function.
* gd_diff.py (get_wiki_mc, push_wiki_page): New functions. * tests/test_gd_diff.py (TestGdDiff.test_push_wiki_page): New method; test for `push_wiki_page` function.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gd_diff.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_gd_diff.py b/tests/test_gd_diff.py
index 22f8a48..a8bac94 100644
--- a/tests/test_gd_diff.py
+++ b/tests/test_gd_diff.py
@@ -11,6 +11,10 @@ import json
import os
import subprocess
import sys
+import time
+import xmlrpc.client
+
+import requests
import gd_diff
@@ -470,6 +474,47 @@ class TestGdDiff(object):
assert wiki_page == gns_wiki_header() + '\n' + wiki_table
+ def test_push_wiki_page(self):
+ url = 'http://localhost:8080'
+ user = 's'
+ passw = 'gtzarko' # "get the zark out"; if you've been wondering.
+ version = '3'
+ content = 'test zarks! @ {}'.format(time.ctime())
+
+ # ensure moin server is running
+ try:
+ r = requests.get(url)
+ a = ''
+ if(r.status_code != 200):
+ return # skip testing
+ except requests.ConnectionError:
+ return # skip testing
+
+ # test
+ expected_barfs = [
+ 'auth success.', 'wiki page updated.',
+ 'auth success.', 'wiki page not updated.',
+ 'auth failure',
+ 'auth failure'
+ ]
+ barfs = []
+ with mock.patch('sys.stdout', new=StringIO()) as output:
+ try:
+ # success
+ push_wiki_page(url, user, passw, version, content)
+ # another success
+ push_wiki_page(url, user, passw, version, content)
+ # auth error
+ push_wiki_page(url, 'z', passw, version, content)
+ # auth error
+ push_wiki_page(url, user, 'zark_out', version, content)
+ barfs = output.getvalue().strip('\n').split('\n')
+ except SystemExit:
+ return # zark it. wiki has disabled xmlrpc.
+
+ assert barfs == expected_barfs
+
+
def test_get_args_gd_diff_version(self):
mock_sys_argv = ['gd-diff', '--version']
with mock.patch('sys.stdout', new=StringIO()) as output, \