specter-desktop/tests/test_checker.py
k9ert 9df0b77f8c
Feature: Spectrum addition (#1952)
* add spectrum

* rc3 of spectrum

* spectrum rc4

* missing __init__.py

* changes for rc6

* make cli-arguments work in electron

* update spectrum to remove simplejson

* Bugfix devices not shown

* additional checks for wallet_import

* nodes template magic to improve extensibility

* smaller bugfixes

* update spectrum

* keep python 3.9 in pre-commit-yaml

* specter_added_to_flask_app callback added

* useful logger + avoid writing to config with no node alias

* Using FlaskThread

* remove overriding chain property in node.py

* nodes_by_chain method added to node mananger

* icons for spectrum setup

* keep external_node and fix test

* bump spectrum version

* more visibility

* deactivate checker_threads for testing

Co-authored-by: k9ert <kim@swanbitcoin.com>
Co-authored-by: Manolis Mandrapilias <70536101+moneymanolis@users.noreply.github.com>
Co-authored-by: moneymanolis <moneymanolis@protonmail.com>
2022-11-30 13:13:16 +01:00

32 lines
1.2 KiB
Python

import logging
import mock
import time
from mock import Mock
from cryptoadvance.specter.util.checker import Checker
def test_checker(caplog):
callback_mock = Mock()
caplog.set_level(logging.DEBUG)
checker = Checker(lambda: callback_mock(), period=0.01, desc="test")
checker.start()
time.sleep(
0.1
) # If the above assumptions are failing, you might want to increase this
assert "Checker test started" in caplog.text
assert "This message won't show again until stopped and started." in caplog.text
checker.stop()
assert "Checker test stopped" in caplog.text
callback_mock.side_effect = Exception("someException")
checker.start()
time.sleep(
2
) # If the above assumptions are failing, you might want to increase this
checker.stop()
assert "someException" in caplog.text
# should output 5 times
assert caplog.text.count("[ ERROR] someException") == 5
# But should also show stacktrace 5 times
assert caplog.text.count("Exception: someException") == 5
assert "The above Error-Message is now suppressed" in caplog.text
assert caplog.text.count("The above Error-Message is now suppressed") == 1