コード例 #1
0
    def test_with_tailing(self, LogsCommandContextMock, click_mock):
        tailing = True
        events_iterable = [1, 2, 3]
        formatted_events = [4, 5, 6]

        context_mock = Mock()
        LogsCommandContextMock.return_value.__enter__.return_value = context_mock

        context_mock.fetcher.tail.return_value = events_iterable
        context_mock.formatter.do_format.return_value = formatted_events

        do_cli(self.function_name, self.stack_name, self.filter_pattern, tailing, self.start_time, self.end_time)

        LogsCommandContextMock.assert_called_with(
            self.function_name,
            stack_name=self.stack_name,
            filter_pattern=self.filter_pattern,
            start_time=self.start_time,
            end_time=self.end_time,
            output_file=None,
        )

        context_mock.fetcher.tail.assert_called_with(
            context_mock.log_group_name, filter_pattern=context_mock.filter_pattern, start=context_mock.start_time
        )

        context_mock.formatter.do_format.assert_called_with(events_iterable)
        click_mock.echo.assert_has_calls([call(v, nl=False) for v in formatted_events])
コード例 #2
0
ファイル: test_command.py プロジェクト: Frameio/aws-sam-cli
    def test_with_tailing(self, LogsCommandContextMock, click_mock):
        tailing = True
        events_iterable = [1, 2, 3]
        formatted_events = [4, 5, 6]

        context_mock = Mock()
        LogsCommandContextMock.return_value.__enter__.return_value = context_mock

        context_mock.fetcher.tail.return_value = events_iterable
        context_mock.formatter.do_format.return_value = formatted_events

        do_cli(self.function_name, self.stack_name, self.filter_pattern, tailing,
               self.start_time, self.end_time)

        LogsCommandContextMock.assert_called_with(self.function_name,
                                                  stack_name=self.stack_name,
                                                  filter_pattern=self.filter_pattern,
                                                  start_time=self.start_time,
                                                  end_time=self.end_time,
                                                  output_file=None)

        context_mock.fetcher.tail.assert_called_with(context_mock.log_group_name,
                                                     filter_pattern=context_mock.filter_pattern,
                                                     start=context_mock.start_time)

        context_mock.formatter.do_format.assert_called_with(events_iterable)
        click_mock.echo.assert_has_calls([call(v, nl=False) for v in formatted_events])