コード例 #1
0
ファイル: test_allow_ssh.py プロジェクト: sen0120/rally-1
    def test_secgroup_setup_cleanup_with_secgroup_supported(
            self, mock_network_wrap, mock__prepare_open_secgroup,
            mock_clients):
        mock_network_wrapper = mock.MagicMock()
        mock_network_wrapper.supports_extension.return_value = (True, "")
        mock_network_wrap.return_value = mock_network_wrapper
        mock__prepare_open_secgroup.return_value = {
            "name": "secgroup",
            "id": "secgroup_id"
        }
        mock_clients.return_value = mock.MagicMock()

        secgrp_ctx = allow_ssh.AllowSSH(self.ctx_with_secgroup)
        secgrp_ctx.setup()
        self.assertEqual(self.ctx_with_secgroup, secgrp_ctx.context)
        secgrp_ctx.cleanup()

        self.assertEqual([
            mock.call("admin_credential"),
            mock.call("credential"),
            mock.call().neutron(),
            mock.call().neutron().delete_security_group("secgroup_id")
        ], mock_clients.mock_calls)

        mock_network_wrap.assert_called_once_with(mock_clients.return_value,
                                                  secgrp_ctx,
                                                  config={})
コード例 #2
0
ファイル: test_allow_ssh.py プロジェクト: ePlusPS/gbp-rally
    def test_secgroup_setup_with_secgroup_unsupported(self, mock_network_wrap,
                                                      mock_clients):
        mock_network_wrapper = mock.MagicMock()
        mock_network_wrapper.supports_extension.return_value = (
            False, "Not supported")
        mock_network_wrap.return_value = mock_network_wrapper
        mock_clients.return_value = mock.MagicMock()

        secgrp_ctx = allow_ssh.AllowSSH(dict(self.ctx_without_secgroup))
        secgrp_ctx.setup()
        self.assertEqual(self.ctx_without_secgroup, secgrp_ctx.context)

        mock_clients.assert_called_once_with("admin_endpoint")

        mock_network_wrap.assert_called_once_with(mock_clients.return_value,
                                                  {})