28 lines
770 B
Python
28 lines
770 B
Python
from ictlogin.cli import _build_parser
|
|
from ictlogin.client import GatewayClient, Status
|
|
|
|
|
|
class _FakeClient(GatewayClient):
|
|
def __init__(self):
|
|
pass
|
|
|
|
def status(self, ip=None):
|
|
return Status(True, {"keepalive_time": "12345"})
|
|
|
|
|
|
def test_heartbeat_extracts_keepalive_marker():
|
|
result = _FakeClient().heartbeat("10.0.0.1")
|
|
assert result.status.online
|
|
assert result.keepalive_time == 12345
|
|
assert result.latency_seconds >= 0
|
|
|
|
|
|
def test_heartbeat_parser_supports_once_and_auto_login():
|
|
args = _build_parser().parse_args(
|
|
["heartbeat", "--once", "--interval", "10", "--auto-login"]
|
|
)
|
|
assert args.command == "heartbeat"
|
|
assert args.once is True
|
|
assert args.interval == 10
|
|
assert args.auto_login is True
|