Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
Added tests for latest fixes and updated changelog.
Browse files Browse the repository at this point in the history
  • Loading branch information
strichter committed Jan 13, 2014
1 parent d3d767e commit 68f0939
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ CHANGES
least 2 replications have been successfully been reported (w=3). It used to
be set to w=1, which blocks until master confirms the write.

- Bug: Ensure that only basic types and not objects derived from any basic
type are treated as such.

- Bug: It can happen that comparing similar dicts can cause decode
errors. This in turn caused some object updates to fail in the data manager.

- Bug: ObjectWriter ``get_collection_name()`` now works properly if the object
writer has no jar. This is the case when we simply want to serialize any
object to JSON, but one of the objects is a proper MongoDB persisted object.
Expand Down
31 changes: 30 additions & 1 deletion src/mongopersist/tests/test_serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from bson import binary, dbref, objectid

from mongopersist import conflict, serialize, testing
from mongopersist import conflict, interfaces, serialize, testing

class Top(persistent.Persistent):
_p_mongo_collection = 'Top'
Expand Down Expand Up @@ -55,6 +55,12 @@ class StoreType2(StoreType):
class Simple(object):
pass

class Constant(object):
def __reduce__(self):
return 'Constant'
Constant = Constant()


def doctest_ObjectSerializer():
"""Test the abstract ObjectSerializer class.
Expand Down Expand Up @@ -314,6 +320,16 @@ def doctest_ObjectWriter_get_state_MONGO_NATIVE_TYPES():
DBRef('4e7ddf12e138237403000000', 'test')
"""

def doctest_ObjectWriter_get_state_constant():
"""ObjectWriter: get_state(): Constants
>>> writer = serialize.ObjectWriter(None)
>>> writer.get_state(Constant)
{'_py_constant': 'mongopersist.tests.test_serialize.Constant'}
>>> writer.get_state(interfaces.IObjectWriter)
{'_py_constant': 'mongopersist.interfaces.IObjectWriter'}
"""

def doctest_ObjectWriter_get_state_types():
"""ObjectWriter: get_state(): types (type, class)
Expand Down Expand Up @@ -874,6 +890,19 @@ def doctest_ObjectReader_get_object_mapping():
{1: '1', 2: '2', 3: '3'}
"""

def doctest_ObjectReader_get_object_constant():
"""ObjectReader: get_object(): constant
>>> reader = serialize.ObjectReader(dm)
>>> reader.get_object(
... {'_py_constant': 'mongopersist.tests.test_serialize.Constant'},
... None)
<mongopersist.tests.test_serialize.Constant object at ...>
>>> reader.get_object(
... {'_py_constant': 'mongopersist.interfaces.IObjectWriter'}, None)
<InterfaceClass mongopersist.interfaces.IObjectWriter>
"""

def doctest_ObjectReader_get_ghost():
"""ObjectReader: get_ghost()
Expand Down

0 comments on commit 68f0939

Please sign in to comment.