MCPcopy Create free account
hub / github.com/MongoEngine/mongoengine / test_q_with_dbref

Method test_q_with_dbref

tests/queryset/test_visitor.py:43–57  ·  view source on GitHub ↗

Ensure Q objects handle DBRefs correctly

(self)

Source from the content-addressed store, hash-verified

41 assert (q1 & q2 & q3 & q4 & q5).to_query(Person) == query
42
43 def test_q_with_dbref(self):
44 """Ensure Q objects handle DBRefs correctly"""
45 connect(db="mongoenginetest")
46
47 class User(Document):
48 pass
49
50 class Post(Document):
51 created_user = ReferenceField(User)
52
53 user = User.objects.create()
54 Post.objects.create(created_user=user)
55
56 assert Post.objects.filter(created_user=user).count() == 1
57 assert Post.objects.filter(Q(created_user=user)).count() == 1
58
59 def test_and_combination(self):
60 """Ensure that Q-objects correctly AND together."""

Callers

nothing calls this directly

Calls 5

QClass · 0.90
connectFunction · 0.85
createMethod · 0.45
countMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected