def do_test(self, mock_release_service_stub, mock_test_release_request, mock_config, _, __): tiller_obj = tiller.Tiller('host', '8080', None) release = 'release' test_suite_run = {} mock_release_service_stub.return_value.RunReleaseTest\ .return_value = grpc_response_mock tiller_obj.get_release_status = mock.Mock() tiller_obj.get_release_status.return_value = AttrDict( **{ 'info': AttrDict( **{ 'status': AttrDict( **{'last_test_suite_run': test_suite_run}), 'Description': 'Failed' }) }) result = tiller_obj.test_release(release) self.assertEqual(test_suite_run, result)
def test_test_release_failure(self): self._test_test_release([ AttrDict(**{ 'msg': 'RUNNING: ...', 'status': helm.TESTRUN_STATUS_RUNNING }), AttrDict(**{ 'msg': 'FAILURE: ...', 'status': helm.TESTRUN_STATUS_FAILURE }) ])
def test_test_release_success(self): self._test_test_release([ AttrDict(**{ 'msg': 'RUNNING: ...', 'status': helm.TESTRUN_STATUS_RUNNING }), AttrDict(**{ 'msg': 'SUCCESS: ...', 'status': helm.TESTRUN_STATUS_SUCCESS }) ])
def test_test_release_no_tests(self): self._test_test_release([ AttrDict(**{ 'msg': 'No Tests Found', 'status': helm.TESTRUN_STATUS_UNKNOWN }) ])
def do_test(_): tiller_obj = tiller.Tiller('host', '8080', None) release = 'release' tiller_obj.test_release = mock.Mock() tiller_obj.test_release.return_value = AttrDict( **{'results': results}) success = test.test_release_for_success(tiller_obj, release) self.assertEqual(expected_success, success)
def fail(tiller, release, timeout=None, cleanup=False): status = AttrDict( **{'info': AttrDict(**{'Description': 'Failed'})}) raise tiller_exceptions.ReleaseException( release, status, 'Test')
def test_update_release(self, mock_release_service_stub, mock_update_release_request, mock_config, _, __): release = 'release' chart = {} namespace = 'namespace' code = 0 status = 'DEPLOYED' description = 'desc' version = 2 values = mock_config(raw=None) mock_release_service_stub.return_value.UpdateRelease.return_value =\ AttrDict(**{ 'release': AttrDict(**{ 'name': release, 'namespace': namespace, 'info': AttrDict(**{ 'status': AttrDict(**{ 'Code': AttrDict(**{ 'Name': lambda c: status if c == code else None }), 'code': code }), 'Description': description }), 'version': version }) }) tiller_obj = tiller.Tiller('host', '8080', None, dry_run=False) # TODO: Test these methods as well, either by unmocking, or adding # separate tests for them. tiller_obj._pre_update_actions = MagicMock() pre_actions = {} post_actions = {} disable_hooks = False wait = True timeout = 123 force = True recreate_pods = True result = tiller_obj.update_release(chart, release, namespace, pre_actions=pre_actions, post_actions=post_actions, disable_hooks=disable_hooks, values=values, wait=wait, timeout=timeout, force=force, recreate_pods=recreate_pods) tiller_obj._pre_update_actions.assert_called_once_with( pre_actions, release, namespace, chart, disable_hooks, values, timeout) mock_update_release_request.assert_called_once_with( chart=chart, name=release, dry_run=tiller_obj.dry_run, disable_hooks=False, values=values, wait=wait, timeout=timeout, force=force, recreate=recreate_pods) mock_release_service_stub.assert_called_once_with(tiller_obj.channel) update_release_stub = mock_release_service_stub.return_value. \ UpdateRelease update_release_stub.assert_called_once_with( mock_update_release_request.return_value, timeout + tiller.GRPC_EPSILON, metadata=tiller_obj.metadata) expected_result = tiller.TillerResult(release, namespace, status, description, version) self.assertEqual(expected_result, result)
def test_running(self): self._test_test_release_for_success(False, [ AttrDict(**{'status': test.TESTRUN_STATUS_SUCCESS}), AttrDict(**{'status': test.TESTRUN_STATUS_RUNNING}) ])
def test_failure(self): self._test_test_release_for_success(False, [ AttrDict(**{'status': test.TESTRUN_STATUS_SUCCESS}), AttrDict(**{'status': test.TESTRUN_STATUS_FAILURE}) ])
def test_success(self): self._test_test_release_for_success( True, [AttrDict(**{'status': test.TESTRUN_STATUS_SUCCESS})])
def test_unknown(self): self._test_test_release_for_success(False, [ AttrDict(**{'status': test.TESTRUN_STATUS_SUCCESS}), AttrDict(**{'status': test.TESTRUN_STATUS_UNKNOWN}) ])