def test_get_status_messages_for_service(self, mock_log, mock_api): mock_client = mock_api.muranoclient(mock.Mock()) mock_client.deployments.list.return_value = [ mock.Mock(id='foo_deployment_id'), mock.Mock(id='bar_deployment_id') ] mock_client.deployments.reports.side_effect = [ [mock.Mock(text='foo_text', created='1970-01-01T12:23:00')], [mock.Mock(text='bar_text', created='1970-01-01T15:45:00')], ] expected_result = '\n1970-01-01 12:23:00 - foo_text\n' \ '1970-01-01 15:45:00 - bar_text\n' expected_reports_mock_calls = [ mock.call('foo_env_id', 'bar_deployment_id', 'foo_service_id'), mock.call('foo_env_id', 'foo_deployment_id', 'foo_service_id') ] result = env_api.get_status_messages_for_service( self.mock_request, self.service_id, self.env_id) self.assertEqual(expected_result, result) mock_client.deployments.reports.assert_has_calls( expected_reports_mock_calls) mock_client.deployments.list.assert_called_once_with('foo_env_id') self.assertTrue(mock_log.debug.called)
def test_get_status_messages_for_service(self, mock_log, mock_api): mock_client = mock_api.muranoclient(mock.Mock()) mock_client.deployments.list.return_value = [ mock.Mock(id='foo_deployment_id'), mock.Mock(id='bar_deployment_id') ] mock_client.deployments.reports.side_effect = [ [mock.Mock(text='foo_text', created='1970-01-01T12:23:00')], [mock.Mock(text='bar_text', created='1970-01-01T15:45:00')], ] expected_result = '\n1970-01-01 12:23:00 - foo_text\n' \ '1970-01-01 15:45:00 - bar_text\n' expected_reports_mock_calls = [ mock.call('foo_env_id', 'bar_deployment_id', 'foo_service_id'), mock.call('foo_env_id', 'foo_deployment_id', 'foo_service_id') ] result = env_api.get_status_messages_for_service( self.mock_request, self.service_id, self.env_id) self.assertEqual(expected_result, result) mock_client.deployments.reports.assert_has_calls( expected_reports_mock_calls) mock_client.deployments.list.assert_called_once_with('foo_env_id') self.assertTrue(mock_log.debug.called)
def get_context_data(self, request): service_id = self.tab_group.kwargs['service_id'] environment_id = self.tab_group.kwargs['environment_id'] reports = api.get_status_messages_for_service(request, service_id, environment_id) return {"reports": reports}
def get_context_data(self, request): service_id = self.tab_group.kwargs['service_id'] environment_id = self.tab_group.kwargs['environment_id'] reports = api.get_status_messages_for_service(request, service_id, environment_id) return {"reports": reports}