예제 #1
0
class TestRunException(object):
    def setup_method(self, method):
        self.ex = RunException('Message', 'exe', ['arg1', 'arg2'], 1, 'out',
                               'err')

    def test_shortstr(self):
        s = 'Message\ncommand: exe arg1 arg2\nreturn code: 1'
        assert self.ex.shortstr() == s

    def test_fullstr(self):
        s = ('Message\ncommand: exe arg1 arg2\nreturn code: 1\n'
             'stdout: out\nstderr: err')
        assert self.ex.fullstr() == s
예제 #2
0
class TestRunException(object):

    def setup_method(self, method):
        self.ex = RunException(
            'Message', 'exe', ['arg1', 'arg2'], 1, 'out', 'err')

    def test_shortstr(self):
        s = 'Message\ncommand: exe arg1 arg2\nreturn code: 1'
        assert self.ex.shortstr() == s

    def test_fullstr(self):
        s = ('Message\ncommand: exe arg1 arg2\nreturn code: 1\n'
             'stdout: out\nstderr: err')
        assert self.ex.fullstr() == s
예제 #3
0
    def test_upgrade_not_initialised(self, dryrun):
        args = self.Args({'dry_run': dryrun})
        db = self.PartialMockDb(args, None)
        self.mox.StubOutWithMock(db, 'get_current_db_version')
        exc = RunException('test psql failure', 'psql', [], -1, '', '')
        db.get_current_db_version().AndRaise(exc)

        self.mox.ReplayAll()

        with pytest.raises(Stop) as excinfo:
            db.upgrade()
        assert excinfo.value.rc == 3
        assert excinfo.value.message == 'Unable to get database version'
        self.mox.VerifyAll()
예제 #4
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()
예제 #5
0
 def setup_method(self, method):
     self.ex = RunException(
         'Message', 'exe', ['arg1', 'arg2'], 1, 'out', 'err')
예제 #6
0
 def setup_method(self, method):
     self.ex = RunException('Message', 'exe', ['arg1', 'arg2'], 1, 'out',
                            'err')