From 01b38957cc6f0819d0cf27393be74c7ef586b081 Mon Sep 17 00:00:00 2001 From: Nattharat Wiriyakulnan Date: Tue, 9 Mar 2021 18:56:58 +0700 Subject: [PATCH] add new test --- helpers/pyband/tests/client/send_tx_test.py | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/helpers/pyband/tests/client/send_tx_test.py b/helpers/pyband/tests/client/send_tx_test.py index 9338490d51..a110f87a09 100644 --- a/helpers/pyband/tests/client/send_tx_test.py +++ b/helpers/pyband/tests/client/send_tx_test.py @@ -7,6 +7,8 @@ TransactionBlockMode, HexBytes, ) +from requests.exceptions import ReadTimeout +from unittest.mock import patch TEST_RPC = "https://api-mock.bandprotocol.com/rest" TEST_MSG = { @@ -68,7 +70,28 @@ } -client = Client(TEST_RPC) +client = Client(TEST_RPC, 3) + + +@patch("requests.post") +def test_send_tx_sync_mode_timeout(requests_mock): + requests_mock.side_effect = ReadTimeout + with pytest.raises(ReadTimeout): + res = client.send_tx_sync_mode(TEST_MSG) + + +@patch("requests.post") +def test_send_tx_block_mode_timeout(requests_mock): + requests_mock.side_effect = ReadTimeout + with pytest.raises(ReadTimeout): + res = client.send_tx_block_mode(TEST_MSG) + + +@patch("requests.post") +def test_send_tx_async_mode_timeout(requests_mock): + requests_mock.side_effect = ReadTimeout + with pytest.raises(ReadTimeout): + res = client.send_tx_async_mode(TEST_MSG) def test_send_tx_sync_mode_success(requests_mock):