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

Method test_using

tests/queryset/test_queryset.py:4382–4397  ·  view source on GitHub ↗

Ensure that switching databases for a queryset is possible

(self)

Source from the content-addressed store, hash-verified

4380 Number.drop_collection()
4381
4382 def test_using(self):
4383 """Ensure that switching databases for a queryset is possible"""
4384
4385 class Number2(Document):
4386 n = IntField()
4387
4388 Number2.drop_collection()
4389 with switch_db(Number2, "test2") as Number2:
4390 Number2.drop_collection()
4391
4392 for i in range(1, 10):
4393 t = Number2(n=i)
4394 t.switch_db("test2")
4395 t.save()
4396
4397 assert len(Number2.objects.using("test2")) == 9
4398
4399 def test_unset_reference(self):
4400 class Comment(Document):

Callers

nothing calls this directly

Calls 6

switch_dbClass · 0.90
Number2Class · 0.85
drop_collectionMethod · 0.80
switch_dbMethod · 0.80
usingMethod · 0.80
saveMethod · 0.45

Tested by

no test coverage detected