def test_FileContentConfiguration_Error(self):
        mock_logger = MagicMock()
        download_resource_mock = MagicMock(side_effect=Exception())

        instance = FileContentConfiguration(
            mock_logger, {}, download_resource=download_resource_mock)

        with self.assertRaises(KuberentesApiInitializationFailedError):
            instance.prepare_api()
Ejemplo n.º 2
0
    def test_FileContentConfiguration_Error(self):
        ctx_mock = MagicMock()

        ctx_mock.download_resource = MagicMock(side_effect=Exception())

        instance = FileContentConfiguration(ctx_mock, {})

        with self.assertRaises(KuberentesApiInitializationFailedError):
            instance.prepare_api()
Ejemplo n.º 3
0
    def test_FileContentConfiguration(self):
        ctx_mock = MagicMock()
        mock_config = MagicMock()
        mock_client = MagicMock()

        instance = FileContentConfiguration(
            ctx_mock, {'file_content': 'kubernetes.conf'})

        with patch('kubernetes.config.kube_config.KubeConfigLoader',
                   mock_config):
            with patch('kubernetes.client', mock_client):
                self.assertEqual(instance.prepare_api(), mock_client)

        mock_config.assert_called_with(config_dict='kubernetes.conf')
    def test_FileContentConfiguration(self):
        mock_download_resource = MagicMock()
        mock_logger = MagicMock()
        mock_config = MagicMock()
        mock_client = MagicMock()

        instance = FileContentConfiguration(
            mock_logger, {'file_content': 'kubernetes.conf'},
            download_resource=mock_download_resource)

        with patch('kubernetes.config.kube_config.KubeConfigLoader',
                   mock_config):
            with patch('kubernetes.client', mock_client):
                self.assertEqual(instance.prepare_api(), mock_client)

        mock_config.assert_called_with(config_dict='kubernetes.conf',
                                       get_google_credentials=ANY)
    def test_FileContentConfiguration(self):
        mock_download_resource = MagicMock()
        mock_logger = MagicMock()
        mock_config = MagicMock()
        mock_client = MagicMock()

        instance = FileContentConfiguration(
            mock_logger,
            {'file_content': 'kubernetes.conf'},
            download_resource=mock_download_resource
        )

        with patch(
            'kubernetes.config.kube_config.KubeConfigLoader', mock_config
        ):
            with patch('kubernetes.client', mock_client):
                self.assertEqual(
                    instance.prepare_api(), mock_client
                )

        mock_config.assert_called_with(
            config_dict='kubernetes.conf',
            config_base_path=os.path.expanduser('~/.kube')
        )