def test_chart_repositories(self): for chart in self.charts: self.assertIsNotNone(chart.repository) self.assertIsInstance(chart.repository, Repository) if chart.name == test_git_repository_chart: self.assertEqual(chart.repository.git, Repository(test_git_repository, mock.Mock()).git) self.assertEqual(chart.repository.path, Repository(test_git_repository, mock.Mock()).path) elif chart.name == test_incubator_repository_chart: self.assertEqual(chart.repository.name, Repository(test_incubator_repository_str, mock.Mock()).name) self.assertIsNone(chart.repository.url)
def setUp(self): super(type(self), self).setUp() self.configure_subprocess_mock(test_repo_update_return_string, '', 0) with open(test_course) as f: self.c = Course(f) self.test_repository = Repository(test_repository_dict, None)
def test_tgz_repository(self): self.configure_subprocess_mock('', '', 0) r = Repository(test_repository_dict) self.assertIsInstance(r, Repository) self.assertEqual(r.name, test_repository_dict['name']) self.assertEqual(r.url, test_repository_dict['url']) self.assertEqual(r.install("test_chart"), Response('', '', 0))
def test_git_repository(self): self.configure_subprocess_mock('', '', 0) r = Repository(test_git_repository) self.assertIsInstance(r, Repository) self.assertEqual(r.git, test_git_repository['git']) self.assertEqual(r.path, test_git_repository['path']) self.assertEqual(r.install("test_chart"), None)
def test_tgz_repository(self): helm_mock = mock.Mock() helm_mock.repositories = [] r = Repository(test_repository_dict, helm_mock) self.assertIsInstance(r, Repository) self.assertEqual(r.name, test_repository_dict['name']) self.assertEqual(r.url, test_repository_dict['url']) assert r.install("test_chart")
def test_git_repository(self, mock_git_lib): helm_mock = mock.Mock() helm_mock.repositories = [] r = Repository(test_git_repository, helm_mock) self.assertIsInstance(r, Repository) self.assertEqual(r.git, test_git_repository['git']) self.assertEqual(r.path, test_git_repository['path']) self.assertEqual(r.install("test_chart"), None)
def setUp(self, mock_helm_client_course_scope, autospec=True): mock_helm_client_course_instance = mock_helm_client_course_scope([]) mock_helm_client_course_instance.version = '100.100.100' super(type(self), self).setUp() self.configure_subprocess_mock(test_repo_update_return_string, '', 0) with open(test_course) as f: self.c = Course(f) self.test_repository = Repository(test_repository_dict, None)
test_archive_pathlet = 'cache/archive' test_helm_archive = "{}/{}".format(test_files_path, test_archive_pathlet) test_helm_args = ['helm', 'version', '--client'] test_helm_version_return_string = 'Client: v2.11.0+g2e55dbe' test_helm_version = '2.11.0' test_helm_repo_return_string = '''NAME URL stable https://kubernetes-charts.storage.googleapis.com local http://127.0.0.1:8879/charts incubator https://kubernetes-charts-incubator.storage.googleapis.com''' test_helm_repo_args = ['helm', 'repo', 'list'] test_helm_repos = [ Repository( { 'url': 'https://kubernetes-charts.storage.googleapis.com', 'name': 'stable' }, mock.Mock()), Repository({ 'url': 'http://127.0.0.1:8879/charts', 'name': 'local' }, mock.Mock()) ] test_tiller_present_return_string = '''NAME REVISION UPDATED STATUS CHART APP VERSION NAMESPACE centrifugo 1 Tue Oct 2 16:19:01 2018 DEPLOYED centrifugo-2.0.1 1.7.3 test ''' test_tiller_present_args = ['helm', 'list'] test_tiller_not_present_return_string = '' test_tiller_not_present_args = ['helm', 'list']
def test_add_repo_for_remote_chart(self, helm_client): repo = Repository(dict(name='testrepo', url='url'), helm_client) repo.install('test_chart') helm_client.repo_add.assert_called()
def test_do_not_add_repo_for_git_chart(self, helm_client): with patch('reckoner.repository.Repository._fetch_from_git'): repo = Repository(dict(name='testrepo', git='../'), helm_client) repo.install('test_chart') helm_client.repo_add.assert_not_called()
def test_do_not_add_repo_for_local_chart(self, helm_client): repo = Repository(dict(name='testrepo', path='../'), helm_client) repo.install('test_chart') helm_client.repo_add.assert_not_called()