from soniclue_basekit.terminable_thread import TerminableThread


def test_not_terminating_by_default():
    t = TerminableThread()
    assert not t.is_terminating()


def test_set_terminating_flips_flag():
    t = TerminableThread()
    t.set_terminating()
    assert t.is_terminating()


def test_log_name_returns_thread_name():
    t = TerminableThread(name="worker")
    assert t._log_name == "worker"


def test_log_name_falls_back_to_class_name():
    t = TerminableThread()
    t.name = ""
    assert t._log_name == "TerminableThread"


def test_format_log_prefixes_name():
    t = TerminableThread(name="srv")
    assert t._format_log("hello") == "[srv] hello"


def test_is_daemon():
    t = TerminableThread()
    assert t.daemon is True
