Ejemplo n.º 1
0
 def test_never(self):
     with pytest.raises(heartbeat.FlicNotFoundError):
         with open(
                 os.path.dirname(__file__) +
                 '/test_files/sample_darkstat_html/never.html',
                 'r') as html_file:
             html = html_file.read()
             heartbeat.parse_flic_last_seen_from_darkstat_html(
                 html, '00:00:00:00:00:02')
Ejemplo n.º 2
0
    def test_log_last_seen_when_darkstat_html_contains_flic_mac_address(self):
        file_path = os.path.dirname(
            __file__) + '/test_files/sample_darkstat_html/log_last_seen.html'
        with open(
                file_path,
                'r') as html_file, patch('heartbeat.logging') as mock_logging:
            html = html_file.read()
            heartbeat.parse_flic_last_seen_from_darkstat_html(
                html, '00:00:00:00:00:02')

            mock_logging.info.assert_called_once_with(
                'darkstat html contains flic last seen info:  <td><a href="./192.168.8.114/">192.168.8.114</a></td>  <td>flic</td>  <td><tt>00:00:00:00:00:02</tt></td>  <td class="num">1 hr, 3 mins, 26 secs</td></tr>'
            )
Ejemplo n.º 3
0
 def test_skips_null_ips_with_matching_mac_address(self):
     with open(
             os.path.dirname(__file__) +
             '/test_files/sample_darkstat_html/null_ips.html',
             'r') as html_file:
         html = html_file.read()
         assert heartbeat.parse_flic_last_seen_from_darkstat_html(
             html, '00:00:00:00:00:02') == 59
Ejemplo n.º 4
0
 def test_seconds_minutes_hours_days(self):
     with open(
             os.path.dirname(__file__) +
             '/test_files/sample_darkstat_html/90206_secs.html',
             'r') as html_file:
         html = html_file.read()
         assert heartbeat.parse_flic_last_seen_from_darkstat_html(
             html, '00:00:00:00:00:02') == 90206
Ejemplo n.º 5
0
 def test_empty_html(self):
     with pytest.raises(heartbeat.FlicNotFoundError):
         heartbeat.parse_flic_last_seen_from_darkstat_html(
             '', '00:00:00:00:00:02')