def test_add_default(self): """connection.add('test', 'mongodb://localhost/test', True)""" con = connection.Connection(uri) try: name = 'test' connection.add(name, con, True) self.assertEquals( connection.connections[None], con, "registered connection is incorrect") finally: con.close() connection.connections = {}
def test_add(self): """connection.add('test')""" name = 'test' uri = 'mongodb://localhost/{}'.format(name) con = connection.Connection(uri) try: connection.add(name) self.assertEquals( connection.connections[name].uri, con.uri, "registered connection is incorrect") finally: con.close() connection.connections = {}
def test_add_config(self): """connection.add('test', {'uri': uri, 'prefix': 'units_'})""" config = {'uri': uri, 'prefix': 'units_'} name = 'test' connection.add(name, config) con = connection.connections[name] try: self.assertEquals( con.database.name, 'test', "registered connection is incorrect") self.assertEquals( con.prefix, config['prefix'], "registered connection is incorrect") finally: con.close() connection.connections = {}
def test_add(self): """connection.add""" con = connection.Connection(uri) try: name = "test" connection.add(name, con) self.assertEquals(connection.connections[name], con, "registered connection is incorrect") finally: con.close() connection.connections = {} config = {"uri": uri, "prefix": "units_"} name = "test" connection.add(name, config) con = connection.connections[name] try: self.assertEquals(con.database.name, "test", "registered connection is incorrect") self.assertEquals(con.prefix, config["prefix"], "registered connection is incorrect") finally: con.close() connection.connections = {}
"""Another MongoDB ODM. * Declarative syntax. * Relatively succinct. * No i18n. * Serious type inference. * Reasonable README, though the README is the only source of example use and is not included in the distribution. * Estimates: 1,214 SLoC, 2.94/3.77 p-months, 0.78 developers. """ from __future__ import unicode_literals from bearfield import connection from bearfield import Document, Field connection.add('example', 'mongodb://localhost/example') class Bear(Document): class Meta: connection = 'example' name = Field(str) type = Field(str) height = Field(float) bear = Bear(name='timmy', type='grizzly', height='9.8') bear.save() types = dict(
* Declarative syntax. * Relatively succinct. * No i18n. * Serious type inference. * Reasonable README, though the README is the only source of example use and is not included in the distribution. * Estimates: 1,214 SLoC, 2.94/3.77 p-months, 0.78 developers. """ from __future__ import unicode_literals from bearfield import connection from bearfield import Document, Field connection.add('example', 'mongodb://localhost/example') class Bear(Document): class Meta: connection = 'example' name = Field(str) type = Field(str) height = Field(float) bear = Bear(name='timmy', type='grizzly', height='9.8') bear.save()