Beispiel #1
0
def test_pick_default_log_mode():
    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.tail_logs',
                    autospec=True) as tail_logs:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True

        logs.pick_default_log_mode(args,
                                   fake_reader,
                                   service=None,
                                   levels=None,
                                   components=None,
                                   clusters=None,
                                   instances=None)

        # Only supports tailing so that's the one that should be used
        assert tail_logs.call_count == 1

    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.print_logs_by_time',
                    autospec=True) as logs_by_time:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True
        fake_reader.SUPPORTS_TIME = True

        logs.pick_default_log_mode(args,
                                   fake_reader,
                                   service=None,
                                   levels=None,
                                   components=None,
                                   clusters=None,
                                   instances=None)

        # Supports tailing and time, but time should be prioritized
        assert logs_by_time.call_count == 1

    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.print_last_n_logs',
                    autospec=True) as logs_by_lines:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True
        fake_reader.SUPPORTS_TIME = True
        fake_reader.SUPPORTS_LINE_COUNT = True

        logs.pick_default_log_mode(args,
                                   fake_reader,
                                   service=None,
                                   levels=None,
                                   components=None,
                                   clusters=None,
                                   instances=None)

        # Supports tailing , time and line counts. Line counts should be prioritized
        assert logs_by_lines.call_count == 1
Beispiel #2
0
def test_pick_default_log_mode():
    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.tail_logs', autospec=True) as tail_logs:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True

        logs.pick_default_log_mode(
            args, fake_reader, service=None, levels=None, components=None, clusters=None, instances=None)

        # Only supports tailing so that's the one that should be used
        assert tail_logs.call_count == 1

    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.print_logs_by_time', autospec=True) as logs_by_time:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True
        fake_reader.SUPPORTS_TIME = True

        logs.pick_default_log_mode(
            args, fake_reader, service=None, levels=None, components=None, clusters=None, instances=None)

        # Supports tailing and time, but time should be prioritized
        assert logs_by_time.call_count == 1

    with mock.patch('paasta_tools.cli.cmds.logs.LogReader.print_last_n_logs', autospec=True) as logs_by_lines:
        args, _ = parse_args(["logs"])

        fake_reader = logs.LogReader()
        fake_reader.SUPPORTS_TAILING = True
        fake_reader.SUPPORTS_TIME = True
        fake_reader.SUPPORTS_LINE_COUNT = True

        logs.pick_default_log_mode(
            args, fake_reader, service=None, levels=None, components=None, clusters=None, instances=None)

        # Supports tailing , time and line counts. Line counts should be prioritized
        assert logs_by_lines.call_count == 1