def test_print_summary_data_mock(capsys, get_data_urlopen_mock): command = cli.Cli('test') resp = sndslib.get_data('test') summary = sndslib.summarize(resp) command._print_summary(summary, ['1.1.1.1']) captured = capsys.readouterr() expected_return = [ 'Date: 09/29/2020 ', 'IPs: 3 ', 'Green: 1 ', 'Yellow: 1 ', 'Red: 1 ', 'Trap Hits: 107 ', 'Blocked: 1', ] for s in expected_return: assert s in captured.out
def summary(self): _summary = sndslib.summarize(self.usage_data) self._print_summary(_summary, self.blocked_ips)
def test_summarize_yellow_count(get_data_urlopen_mock): resp = sndslib.get_data('test') summary = sndslib.summarize(resp) assert summary['yellow'] == 1
def test_summarize_return_dict(get_data_urlopen_mock): resp = sndslib.get_data('test') summary = sndslib.summarize(resp) assert isinstance(summary, dict)