Ejemplo n.º 1
0
    def test_check_connection(self, connected):
        db = self.PartialMockDb(None, None)
        self.mox.StubOutWithMock(db, 'psql')

        if connected:
            db.psql('-c', r'\conninfo')
        else:
            db.psql('-c',
                    r'\conninfo').AndRaise(RunException('', '', [], 1, '', ''))
        self.mox.ReplayAll()

        if connected:
            db.check_connection()
        else:
            with pytest.raises(Stop) as excinfo:
                db.check_connection()
            assert str(excinfo.value) == 'Database connection check failed'

        self.mox.VerifyAll()
Ejemplo n.º 2
0
Archivo: test_db.py Proyecto: ome/omego
    def test_check_connection(self, connected):
        db = self.PartialMockDb(None, None)
        self.mox.StubOutWithMock(db, 'psql')

        if connected:
            db.psql('-c', r'\conninfo')
        else:
            db.psql('-c', r'\conninfo').AndRaise(
                RunException('', '', [], 1, '', ''))
        self.mox.ReplayAll()

        if connected:
            db.check_connection()
        else:
            with pytest.raises(Stop) as excinfo:
                db.check_connection()
            assert str(excinfo.value) == 'Database connection check failed'

        self.mox.VerifyAll()