From 831545ef2c0b15527ccc4974eb20178ae4d65f05 Mon Sep 17 00:00:00 2001 From: Salvatore Ingala <6681844+bigspider@users.noreply.github.com> Date: Thu, 10 Oct 2019 09:54:50 +0700 Subject: [PATCH] Added simple tests for check_txid_format --- test/unit/test_tools.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/unit/test_tools.py diff --git a/test/unit/test_tools.py b/test/unit/test_tools.py new file mode 100644 index 0000000..ba5b834 --- /dev/null +++ b/test/unit/test_tools.py @@ -0,0 +1,16 @@ +from pisa.tools import check_txid_format +from pisa import logging + +logging.getLogger().disabled = True + + +def test_check_txid_format(): + assert(check_txid_format(None) is False) + assert(check_txid_format("") is False) + assert(check_txid_format(0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef) is False) # wrong type + assert(check_txid_format("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") is True) # lowercase + assert(check_txid_format("0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF") is True) # uppercase + assert(check_txid_format("0123456789abcdef0123456789ABCDEF0123456789abcdef0123456789ABCDEF") is True) # mixed case + assert(check_txid_format("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdf") is False) # too short + assert(check_txid_format("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0") is False) # too long + assert(check_txid_format("g123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef") is False) # non-hex