Exemplo n.º 1
0
 def test_connection_with_statement(self):
     """ Test the with statement alternate connection """
     with mogo.session(ALTDB) as s:
         foo = Foo.use(s)(bar=u"testing_with_statement")
         foo.save(safe=True)
         results = Foo.use(s).find({"bar": "testing_with_statement"})
         self.assertEqual(results.count(), 1)
         result = results.first()
         self.assertEqual(result, foo)
     count = Foo.find().count()
     self.assertEqual(count, 0)
Exemplo n.º 2
0
 def test_connection_with_statement(self):
     """ Test the with statement alternate connection """
     with mogo.session(ALTDB) as s:
         foo = Foo.use(s)(bar=u"testing_with_statement")
         foo.save(safe=True)
         results = Foo.use(s).find({"bar": "testing_with_statement"})
         self.assertEqual(results.count(), 1)
         result = results.first()
         self.assertEqual(result, foo)
     count = Foo.find().count()
     self.assertEqual(count, 0)
Exemplo n.º 3
0
 def test_session(self):
     """ Test using a session on a model """
     foo = Foo()
     foo.save(safe=True)
     self.assertEqual(Foo.find().count(), 1)
     session = mogo.session(ALTDB)
     session.connect()
     FooWrapped = Foo.use(session)
     self.assertEqual(FooWrapped._get_name(), Foo._get_name())
     self.assertEqual(FooWrapped.find().count(), 0)
     coll = session.connection.get_collection("foo")
     self.assertEqual(coll.find().count(), 0)
     foo2 = FooWrapped()
     foo2.save(safe=True)
     self.assertEqual(coll.find().count(), 1)
     session.close()
Exemplo n.º 4
0
 def test_session(self):
     """ Test using a session on a model """
     foo = Foo()
     foo.save(safe=True)
     self.assertEqual(Foo.find().count(), 1)
     session = mogo.session(ALTDB)
     session.connect()
     FooWrapped = Foo.use(session)
     self.assertEqual(FooWrapped._get_name(), Foo._get_name())
     self.assertEqual(FooWrapped.find().count(), 0)
     coll = session.connection.get_collection("foo")
     self.assertEqual(coll.find().count(), 0)
     foo2 = FooWrapped()
     foo2.save(safe=True)
     self.assertEqual(coll.find().count(), 1)
     session.disconnect()