test_cli.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:aws-ssh 作者: arusahni 项目源码 文件源码
def test_get_ssh_args_instance_name(env_mock, exit_mock):
    with patch('os.getcwd') as cwd_mock:
        cwd_mock.return_value = '/path/to/cwd'
        project = MagicMock()
        key_path_mock = PropertyMock(return_value='/path/to/key.pem')
        type(project).key_path = key_path_mock
        env_mock.is_initialized.return_value = True
        env_mock.return_value.find_project.return_value = project
        instance = MagicMock()
        ip_mock = PropertyMock(return_value='0.0.0.0')
        type(instance).ip = ip_mock
        instance.get_user_name.return_value = 'test_user'
        project.get_instance.return_value = instance
        args = cli.get_ssh_args(['fooinst'])
        env_mock.return_value.find_project.assert_called_with('/path/to/cwd')
        project.get_instance.assert_called_with('fooinst')
        key_path_mock.assert_called_with()
        instance.get_user_name.assert_called_with()
        ip_mock.assert_called_with()
        assert len(args) == 3
        assert args[0] == '/path/to/key.pem'
        assert args[1] == 'test_user'
        assert args[2] == '0.0.0.0'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号