Exemple #1
0
def test_format_ip_data(capsys, get_data_urlopen_mock):
    command = cli.Cli('test')
    ipdata = sndslib.search_ip_status('1.1.1.2', command.usage_data)
    command._print_ip_data(ipdata)
    captured = capsys.readouterr()
    expected_return = [
        'Activity: 12/31/2019 9:00 PM until 9/29/2020 9:00 PM ',
        'IP:         1.1.1.2 ',
        'Messages:     12960 ',
        'Filter:         RED ',
        'Complaint:   < 0.1% ',
        'Trap Hits:       26 ',
    ]
    for s in expected_return:
        assert s in captured.out
Exemple #2
0
def test_search_ip_status_return_success(get_data_urlopen_mock):
    resp = sndslib.get_data('test')
    resp_dict = sndslib.search_ip_status('1.1.1.0', resp)
    expected_return = {
        'ip_address': '1.1.1.0',
        'activity_start': '12/31/2019 8:00 AM',
        'activity_end': '9/29/2020 9:00 PM',
        'rcpt_commands': '14129',
        'data_commands': '14129',
        'message_recipients': '13025',
        'filter_result': 'GREEN',
        'complaint_rate': '< 0.1%',
        'trap_message_start': '9/29/2020 8:07 AM',
        'trap_message_end': '9/29/2020 12:03 PM',
        'traphits': '41',
        'sample_helo': '',
        'sample_mailfrom': '',
        'comments': ''
    }
    assert resp_dict == expected_return
Exemple #3
0
 def ip_data(self, ip):
     _ip_data = sndslib.search_ip_status(ip, self.usage_data)
     if _ip_data:
         self._print_ip_data(_ip_data)
     else:
         print('No data found for the given IP.')
Exemple #4
0
def test_search_ip_status_return_failure_type(get_data_urlopen_mock):
    resp = sndslib.get_data('test')
    resp_dict = sndslib.search_ip_status('0.0.0.0', resp)
    assert isinstance(resp_dict, dict)
Exemple #5
0
def test_search_ip_status_return_failure(get_data_urlopen_mock):
    resp = sndslib.get_data('test')
    resp_dict = sndslib.search_ip_status('0.0.0.0', resp)
    assert bool(resp_dict) is False