def test_non_existent_versions(self): """Test that we only accept 2 or 3 for helm version""" with self.assertRaises(HelmClientException): provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = [] get_helm_client([], client_version="1001", helm_provider=provider_mock)
def test_handling_err_get_client(self): """Test error handling for helm output""" provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = mock_execute_unknown_helm_provider # Tests if we pass a non-conforming version string with a healthy exit code based on helm 3 not supporting --client with self.assertRaises(HelmClientException): get_helm_client([], helm_provider=provider_mock) provider_mock.execute.side_effect = Exception( 'totally unexpected exception') with self.assertRaises(HelmClientException): get_helm_client([], helm_provider=provider_mock)
def test_static_version_selection(self): """Test that when we explicitly want helm2 or helm3 we get that "client" class""" provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = mock_execute_helm2provider helm_client = get_helm_client([], client_version="2", helm_provider=provider_mock) self.assertIsInstance(helm_client, Helm2Client) provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = mock_execute_helm3provider helm_client = get_helm_client([], client_version="3", helm_provider=provider_mock) self.assertIsInstance(helm_client, Helm3Client)
def test_get_helm_3_client(self): """Test getting a helm 3 client when passed certian info""" provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = mock_execute_helm3provider helm_client = get_helm_client([], helm_provider=provider_mock) self.assertIsInstance(helm_client, Helm3Client)
def test_get_helm_2_client(self): """Test to make sure we get a helm 2 client when passed certain information""" provider_mock = mock.MagicMock(HelmProvider, autospec=True) provider_mock.execute.side_effect = mock_execute_helm2provider helm_client = get_helm_client([], helm_provider=provider_mock) self.assertIsInstance(helm_client, Helm2Client)