Beispiel #1
0
def ensure_results(mocker, event_loop, output_format, time_range, entry_count):
    """Ensure we get the right amount of entries."""
    result, _ = event_loop.run_until_complete(
        apd.async_retrieve(pages=-1, **time_range))
    assert result is not None
    assert len(result) == entry_count
    assert isinstance(result, list)
    if result:
        assert isinstance(result[0], dict)
Beispiel #2
0
def ensure_results(mocker, event_loop, output_format, time_range, entry_count):
    """Ensure we get the right amount of entries."""
    results, _ = event_loop.run_until_complete(apd.async_retrieve(pages=-1, **time_range))
    assert results is not None
    assert len(results) == entry_count
    assert isinstance(results, list)
    if results:
        assert isinstance(results[0], dict)

    # Get the format and print the results.
    format_ = output_format['format'].lower()
    formatter = Formatter(format_)
    formatter.print(results)
Beispiel #3
0
    def _execute(self):
        """Define the internal execution of the command."""
        # Collect the results.
        results, _ = asyncio.run(
            apd.async_retrieve(
                self.args['pages'],
                self.args['from_'],
                self.args['to'],
            ))
        result_count = len(results)
        logger.info(f'Total: {result_count}')

        # Get the format and print the results.
        format_ = self.args['format_'].lower()
        formatter = Formatter(format_)
        formatter.print(results)
Beispiel #4
0
def ensure_results(mocker, event_loop, output_format, time_range, crash_count,
                   fatality_count):
    """Ensure we get the right amount of entries."""
    results, _ = event_loop.run_until_complete(
        apd.async_retrieve(pages=-1, **time_range))
    assert results is not None
    assert isinstance(results, list)
    assert isinstance(results[0], model.Report)
    assert len(results) == crash_count
    assert sum([len(report.fatalities)
                for report in results]) == fatality_count

    # Get the format and print the results.
    format_ = output_format['format'].lower()
    formatter = Formatter(format_)
    formatter.print(results)