Added testcase for MongoEngine/mongoengine#77
This commit is contained in:
parent
9989da07ed
commit
4c8296acc6
@ -1268,7 +1268,6 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
published_posts = (post1, post2, post3, post5, post6)
|
published_posts = (post1, post2, post3, post5, post6)
|
||||||
self.assertTrue(all(obj.id in posts for obj in published_posts))
|
self.assertTrue(all(obj.id in posts for obj in published_posts))
|
||||||
|
|
||||||
|
|
||||||
# Check Q object combination
|
# Check Q object combination
|
||||||
date = datetime(2010, 1, 10)
|
date = datetime(2010, 1, 10)
|
||||||
q = BlogPost.objects(Q(publish_date__lte=date) | Q(published=True))
|
q = BlogPost.objects(Q(publish_date__lte=date) | Q(published=True))
|
||||||
@ -1327,6 +1326,27 @@ class QuerySetTest(unittest.TestCase):
|
|||||||
|
|
||||||
BlogPost.drop_collection()
|
BlogPost.drop_collection()
|
||||||
|
|
||||||
|
def test_raw_query_and_Q_objects(self):
|
||||||
|
"""
|
||||||
|
Test raw plays nicely
|
||||||
|
"""
|
||||||
|
class Foo(Document):
|
||||||
|
name = StringField()
|
||||||
|
a = StringField()
|
||||||
|
b = StringField()
|
||||||
|
c = StringField()
|
||||||
|
|
||||||
|
meta = {
|
||||||
|
'allow_inheritance': False
|
||||||
|
}
|
||||||
|
|
||||||
|
query = Foo.objects(__raw__={'$nor': [{'name': 'bar'}]})._query
|
||||||
|
self.assertEqual(query, {'$nor': [{'name': 'bar'}]})
|
||||||
|
|
||||||
|
q1 = {'$or': [{'a': 1}, {'b': 1}]}
|
||||||
|
query = Foo.objects(Q(__raw__=q1) & Q(c=1))._query
|
||||||
|
self.assertEqual(query, {'$or': [{'a': 1}, {'b': 1}], 'c': 1})
|
||||||
|
|
||||||
def test_exec_js_query(self):
|
def test_exec_js_query(self):
|
||||||
"""Ensure that queries are properly formed for use in exec_js.
|
"""Ensure that queries are properly formed for use in exec_js.
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user