GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit 3efb6867 authored by juga  's avatar juga 💬

fix: test: Check that log prints a number

and not a list of timestamps.
parent e9d5bb08
......@@ -45,7 +45,7 @@ class Heartbeat(object):
Log the percentage, the number of relays measured and not measured,
the number of loops and the time elapsed since it started measuring.
"""
loops_count = self.state_dict.get('recent_priority_list_count', 0)
loops_count = self.state_dict.count('recent_priority_list')
not_measured_fp_set = self.consensus_fp_set.difference(
self.measured_fp_set
......
......@@ -2,9 +2,12 @@
import logging
from sbws.lib import heartbeat
from sbws.util.state import State
def test_total_measured_percent(conf, caplog):
state = State(conf["paths"]["state_fname"])
state["recent_priority_list"] = [1, 2, 3]
hbeat = heartbeat.Heartbeat(conf.getpath('paths', 'state_fname'))
hbeat.register_consensus_fprs(['A', 'B', 'C'])
......@@ -19,6 +22,7 @@ def test_total_measured_percent(conf, caplog):
hbeat.print_heartbeat_message()
assert hbeat.previous_measurement_percent == 67
assert 0 == caplog.records[0].getMessage().find("Run 3 main loops.")
assert 0 == caplog.records[1].getMessage().find(
"Measured in total 2 (67%)"
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment