def test_no_retry_when_filenotfound(config, mocker): KrbCommand.kdestroy(config) raise_exception = [FileNotFoundError, None] patcher = mocker.patch('subprocess.check_output', side_effect=raise_exception) try: KrbCommand.kinit(config) pytest.fail() except FileNotFoundError: assert patcher.call_count == 1
def test_retry(config, mocker): KrbCommand.kdestroy(config) raise_exception_twice = [ subprocess.CalledProcessError(1, ['kinit']), subprocess.CalledProcessError(1, ['kinit']), None ] patcher = mocker.patch('subprocess.check_output', side_effect=raise_exception_twice) KrbCommand.kinit(config) assert patcher.call_count == 3
def _test_commands(config): KrbCommand.kdestroy(config) KrbCommand.kinit(config) KrbCommand.renewal(config) KrbCommand.klist(config) KrbCommand.kdestroy(config)
def test_kinit_command(config, expected, mocker): mocker.patch.object(KrbCommand, '_call') KrbCommand.kinit(config) KrbCommand._call.assert_called_with(config, expected)