summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJacob Mason <jacoblmason@gmail.com>2010-08-04 13:09:07 -0500
committerJacob Mason <jacoblmason@gmail.com>2010-08-04 13:09:07 -0500
commit75ae087f7aece6b81c20a37641b363dc23ad5e83 (patch)
tree4c9b0b52d798f1a536fa897c9fa2767ccd8e3d89 /tests
parent248c01af3ec09ce34bb39ef43605c2ce37896bd8 (diff)
downloadsphinx-git-75ae087f7aece6b81c20a37641b363dc23ad5e83.tar.gz
added more test coverage.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_searchadapters.py4
-rw-r--r--tests/test_websupport.py48
2 files changed, 45 insertions, 7 deletions
diff --git a/tests/test_searchadapters.py b/tests/test_searchadapters.py
index 94f72cab4..186b2e429 100644
--- a/tests/test_searchadapters.py
+++ b/tests/test_searchadapters.py
@@ -59,7 +59,9 @@ def search_adapter_helper(adapter):
assert len(results) == 1, \
'%s search adapter returned %s search result(s), should have been 1'\
% (adapter, len(results))
-
+ # Make sure it works through the WebSupport API
+ html = support.get_search_results(u'SomeLongRandomWord')
+
def test_xapian():
# Don't run tests if xapian is not installed.
diff --git a/tests/test_websupport.py b/tests/test_websupport.py
index 5e0326047..464c8c74b 100644
--- a/tests/test_websupport.py
+++ b/tests/test_websupport.py
@@ -14,7 +14,9 @@ from StringIO import StringIO
from sphinx.websupport import WebSupport
from sphinx.websupport.errors import *
-from sphinx.websupport.comments.sqlalchemystorage import Session
+from sphinx.websupport.comments.differ import CombinedHtmlDiff
+from sphinx.websupport.comments.sqlalchemystorage import Session, \
+ SQLAlchemyStorage
from sphinx.websupport.comments.db import Node
from util import *
@@ -25,6 +27,10 @@ except ImportError:
wraps = lambda f: (lambda w: w)
+default_settings = {'outdir': os.path.join(test_root, 'websupport'),
+ 'status': StringIO(),
+ 'warning': StringIO()}
+
def teardown_module():
(test_root / 'generated').rmtree(True)
(test_root / 'websupport').rmtree(True)
@@ -32,9 +38,7 @@ def teardown_module():
def with_support(*args, **kwargs):
"""Make a WebSupport object and pass it the test."""
- settings = {'outdir': os.path.join(test_root, 'websupport'),
- 'status': StringIO(),
- 'warning': StringIO()}
+ settings = default_settings.copy()
settings.update(kwargs)
def generator(func):
@@ -104,8 +108,17 @@ def test_comments(support):
assert len(children) == 1
assert children[0]['text'] == 'Child test comment'
+
+@with_support()
+def test_voting(support):
+ session = Session()
+ nodes = session.query(Node).all()
+ node = nodes[0]
+
+ comment = support.get_comments(str(node.id))['comments'][0]
+
def check_rating(val):
- data = support.get_comments(str(first_node.id))
+ data = support.get_comments(str(node.id))
comment = data['comments'][0]
assert comment['rating'] == val, '%s != %s' % (comment['rating'], val)
@@ -124,6 +137,29 @@ def test_comments(support):
# Make sure past voting data is associated with comments when they are
# fetched.
- data = support.get_comments(str(first_node.id), username='user_two')
+ data = support.get_comments(str(node.id), username='user_two')
comment = data['comments'][0]
assert comment['vote'] == 1, '%s != 1' % comment['vote']
+
+@with_support()
+def test_proposals(support):
+ session = Session()
+ nodes = session.query(Node).all()
+ node = nodes[0]
+
+ data = support.get_comments(str(node.id))
+
+ source = data['source']
+ proposal = source[:5] + source[10:15] + 'asdf' + source[15:]
+
+ comment = support.add_comment('Proposal comment',
+ node_id=str(node.id),
+ proposal=proposal)
+
+def test_differ():
+ differ = CombinedHtmlDiff()
+ source = 'Lorem ipsum dolor sit amet,\nconsectetur adipisicing elit,\n' \
+ 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
+ prop = 'Lorem dolor sit amet,\nconsectetur nihil adipisicing elit,\n' \
+ 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'
+ differ.make_html(source, prop)