Update mongomock example
Improved the mongomock example as reported in #2067 Fixes #2067
This commit is contained in:
parent
048a045966
commit
5bf1dd55b1
@ -19,3 +19,30 @@ or with an alias:
|
||||
|
||||
connect('mongoenginetest', host='mongomock://localhost', alias='testdb')
|
||||
conn = get_connection('testdb')
|
||||
|
||||
Example of test file:
|
||||
--------
|
||||
.. code-block:: python
|
||||
|
||||
import unittest
|
||||
from mongoengine import connect, disconnect
|
||||
|
||||
class Person(Document):
|
||||
name = StringField()
|
||||
|
||||
class TestPerson(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
connect('mongoenginetest', host='mongomock://localhost')
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
disconnect()
|
||||
|
||||
def test_thing(self):
|
||||
pers = Person(name='John')
|
||||
pers.save()
|
||||
|
||||
fresh_pers = Person.objects().first()
|
||||
self.assertEqual(fresh_pers.name, 'John')
|
||||
|
Loading…
x
Reference in New Issue
Block a user