Пример #1
0
    def test_is_backend_avail(self):
        self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
        fake_connection = self.mox.CreateMockAnything()
        fake_connection.close()
        sqlalchemy.engine.base.Engine.connect().AndReturn(fake_connection)
        self.mox.ReplayAll()

        self.assertTrue(utils.is_backend_avail(**self.full_credentials))
Пример #2
0
    def test_is_backend_avail(self):
        self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
        fake_connection = self.mox.CreateMockAnything()
        fake_connection.close()
        sqlalchemy.engine.base.Engine.connect().AndReturn(fake_connection)
        self.mox.ReplayAll()

        self.assertTrue(utils.is_backend_avail(**self.full_credentials))
Пример #3
0
 def test_is_backend_unavail(self):
     log = self.useFixture(fixtures.FakeLogger())
     err = OperationalError("Can't connect to database", None, None)
     error_msg = "The postgresql backend is unavailable: %s\n" % err
     self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
     sqlalchemy.engine.base.Engine.connect().AndRaise(err)
     self.mox.ReplayAll()
     self.assertFalse(utils.is_backend_avail(**self.full_credentials))
     self.assertEqual(error_msg, log.output)
Пример #4
0
 def test_is_backend_unavail(self):
     log = self.useFixture(fixtures.FakeLogger())
     err = OperationalError("Can't connect to database", None, None)
     error_msg = "The postgresql backend is unavailable: %s\n" % err
     self.mox.StubOutWithMock(sqlalchemy.engine.base.Engine, 'connect')
     sqlalchemy.engine.base.Engine.connect().AndRaise(err)
     self.mox.ReplayAll()
     self.assertFalse(utils.is_backend_avail(**self.full_credentials))
     self.assertEqual(error_msg, log.output)