Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Wrote a test for query hashing (issue #5).

  • Loading branch information...
commit e1de334e8fa05a0db326bd525304f84dc090fe2b 1 parent 1b30a8c
@mhluongo mhluongo authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 lucenequerybuilder/tests.py
View
19 lucenequerybuilder/tests.py
@@ -4,7 +4,6 @@
"""
from lucenequerybuilder import Q
-import re
def test_general():
a = 'a'
@@ -38,6 +37,24 @@ def test_simple_phrase():
query_string = str(Q('abc 123'))
assert query_string == '"abc 123"', query_string
+def test_hashing():
+ q1 = Q('a') & Q('b') | Q('c')
+ q2 = Q('a') & Q('b') | Q('c')
+ q3 = q1 | Q('d')
+
+ assert q1 == q2, "Queries aren't being properly evaluated for equality."
+ assert q2 != q3, "Queries aren't being properly evaluated for inequality."
+
+ d = {}
+ try:
+ d[q1] = 1
+ d[q2] = 2
+ except:
+ raise AssertionError('There was an error using queries as dict keys.')
+ assert d[q1] == 1, 'Got the wrong value back from the query dict!'
+ assert d[q2] == 2, 'Got the wrong value back from the query dict!'
+
+
#this test doesn't work, but might be worth rewriting
#
#def test_escaping():
Please sign in to comment.
Something went wrong with that request. Please try again.