Пример #1
0
 def test_success(self):
     mock_ver_api = FakeK8sApi(False)
     mock_api_client = MagicMock()
     mock_api_client.host = self.DEFAULT_K8S_NAME
     with patch(_BUILTINS_PRINT) as mock_print:
         _cluster_probe_connection(mock_ver_api, mock_api_client)
         mock_print.assert_called_once_with("Connect {} [ok]".format(self.DEFAULT_K8S_NAME))
 def test_no_connection_with_k8s(self):
     mock_api_client = MagicMock()
     mock_api_client.host = self.DEFAULT_K8S_NAME
     mock_ver_api = FakeK8sApi(True)
     self.assertRaises(SystemExit,
                       _cluster_probe_connection,
                       api=mock_ver_api,
                       api_client=mock_api_client)
Пример #3
0
    def _check_internal_fn_causes_systemexit(self, mock_dict,
                                             expected_err_msg):
        mock_dict['get_k8s_client'].return_value = FakeK8sApi(False)
        mock_dict['version_api'].return_value = MagicMock()
        mock_dict['core_api'].return_value = MagicMock()
        mock_dict['extensions_api'].return_value = MagicMock()

        util = APSConnectUtil()

        with patch(_BUILTINS_PRINT) as mock_print:
            with patch(_BUILTINS_OPEN, self._read_valid_json()) as mock_file:
                self.assertRaises(SystemExit,
                                  util.install_backend,
                                  name=self._TEST_NAME,
                                  image='',
                                  config_file=FakeData.CONFIG_PATH,
                                  hostname='localhost')
                mock_file.assert_has_calls([call(FakeData.CONFIG_PATH)])
                mock_print.assert_called_with(expected_err_msg)
Пример #4
0
 def _setup_external_api_mocks(self, mocks_dict):
     mocks_dict['get_k8s_client'].return_value = FakeK8sApi(False)
     mocks_dict['version_api'].return_value = MagicMock()
     mocks_dict['core_api'].return_value = MagicMock()
     mocks_dict['extensions_api'].return_value = MagicMock()