Metadata-Version: 1.0
Name: m01.stub
Version: 0.5.0
Summary: MongoDB server stub setup
Home-page: http://pypi.python.org/pypi/m01.stub
Author: Roger Ineichen, Projekt01 GmbH
Author-email: dev@projekt01.ch
License: ZPL 2.1
Description: This package provides a mongodb server stub setup for python doctests.
        
        
        ======
        README
        ======
        
        This package provides a mongo database server testing stub. You can simply
        setup such a mongodb stub server in a doctest like::
        
          import doctest
          import unittest
          
          from m01.stub import testing
          
          def test_suite():
              return unittest.TestSuite((
                  doctest.DocFileSuite('README.txt',
                      setUp=testing.doctestSetUp,
                      tearDown=testing.doctestTearDown,
                      optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS),
                  ))
          
          
          if __name__ == '__main__':
              unittest.main(defaultTest='test_suite')
        
        The m01/stub/testing.py module provides a start and stop method which will
        download, install, start and stop a mongodb server. All this is done in the
        m01/stub/testing/sandbox folder. Everytime a test get started the mongodb/data
        folder get removed and a fresh empty database get used.
        
        Note: Also see the zipFolder and unZipFile methods in testing.py which allows
        you to setup mongodb data and before remove them store them as a zip file
        for a next test run. Such a zipped data folder can get used in another test run
        by set the path to the zip file as dataSource argument. Also check the
        m01.mongo package for more test use cases.
        
        
        Testing
        -------
        
        Let's use the pymongo package for test our mongodb server stub setup. Note we
        use a different port for our stub server setup (45017 instead of 27017):
        
          >>> from pprint import pprint
          >>> import pymongo
          >>> conn = pymongo.Connection('localhost', 45017)
        
        Let's test our mongodb stub setup:
        
          >>> pprint(conn.server_info())
          {u'bits': 32,
           u'debug': False,
           u'gitVersion': u'...',
           u'maxBsonObjectSize': ...,
           u'ok': 1.0,
           u'sysInfo': ...,
           u'version': u'1.8.2'}
        
          >>> conn.database_names()
          [u'admin', u'local']
        
        setup an index:
        
          >>> conn.testing.test.collection.ensure_index('dummy')
          u'dummy_1'
        
        add an object:
        
          >>> _id = conn.testing.test.save({'__name__': u'foo', 'dummy': u'object'})
          >>> _id
          ObjectId('...')
        
        remove them:
        
          >>> conn.testing.test.remove({'_id': _id})
        
        and check the database names again:
        
          >>> conn.database_names()
          [u'testing', u'admin', u'local']
        
        Let's drop the database:
        
          >>> conn.drop_database("testing")
          >>> conn.database_names()
          [u'admin', u'local']
        
        
        
        =======
        CHANGES
        =======
        
        0.5.0 (2011-08-19)
        ------------------
        
        - initial release tested on win 32bit. NOT tested on win 64bit, mac 32/64bit
          and posix 32/64bit systems. Please report if something doesn't work on this
          systems.
        
Keywords: Zope3 z3c p01 m01 mongodb server stub setup
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Zope Public License
Classifier: Programming Language :: Python
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: Zope3
