Skip to content

Commit

Permalink
remove testcase:test_signals_with_switch_sharding_db() and fix code s…
Browse files Browse the repository at this point in the history
…tyle error for pull#1020
  • Loading branch information
9nix00 committed Jun 21, 2015
1 parent dfc7f35 commit 41bff0b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 50 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.rst
Expand Up @@ -5,7 +5,7 @@ Changelog

Changes in 0.9.X - DEV
======================
- improve Document._created status when switch collection and db #1020
- Improve Document._created status when switch collection and db #1020
- Queryset update doesn't go through field validation #453
- Added support for specifying authentication source as option `authSource` in URI. #967
- Fixed mark_as_changed to handle higher/lower level fields changed. #927
Expand Down
6 changes: 2 additions & 4 deletions mongoengine/document.py
Expand Up @@ -503,8 +503,7 @@ def switch_db(self, db_alias, keep_created=True):
:param str db_alias: The database alias to use for saving the document
:param bool keep_created: keep self._created value after call `swith_db()` when True,
else will always set self._created value to True
:param bool keep_created: keep self._created value after switching db, else is reset to True
.. seealso::
Expand Down Expand Up @@ -535,8 +534,7 @@ def switch_collection(self, collection_name, keep_created=True):
:param str collection_name: The database alias to use for saving the
document
:param bool keep_created: keep self._created value after call `swith_db()` when True,
else will always set self._created value to True
:param bool keep_created: keep self._created value after switching collection, else is reset to True
.. seealso::
Expand Down
45 changes: 0 additions & 45 deletions tests/test_signals.py
Expand Up @@ -306,51 +306,6 @@ def test_signals_with_switch_db(self):
ei.switch_db("testdb-1", keep_created=False)
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])

def test_signals_with_switch_sharding_db(self):

import pymongo
from mongoengine.connection import get_connection

connect('mongoenginetest', alias='testdb1')
expected_connection = get_connection('testdb1')

connect('mongoenginetest', alias='testdb2')
actual_connection = get_connection('testdb2')

if pymongo.version_tuple[0] < 3:
IS_PYMONGO_3 = False
else:
IS_PYMONGO_3 = True

ei = self.ExplicitId(id=123)
ei.switch_db("testdb1")
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])
ei.switch_db("testdb1")
self.assertEqual(self.get_signal_output(ei.save), ['Is updated'])

ei.switch_db("testdb2", keep_created=False)
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])
ei.switch_db("testdb2", keep_created=False)
self.assertEqual(self.get_signal_output(ei.save), ['Is created'])

# Handle PyMongo 3+ Async Connection
if IS_PYMONGO_3:
# Ensure we are connected, throws ServerSelectionTimeoutError otherwise.
# Purposely not catching exception to fail test if thrown.
expected_connection.server_info()

self.assertEqual(expected_connection, actual_connection)












if __name__ == '__main__':
unittest.main()

0 comments on commit 41bff0b

Please sign in to comment.