From d8e36c13ae47e0b9a5d309fd79c8d7a8a499d2db Mon Sep 17 00:00:00 2001
From: Moul <moul@moul.re>
Date: Wed, 1 Jul 2020 20:21:20 +0200
Subject: [PATCH] [test] Improve 'verify' tests

Harmonize by calling top-level click cmds group in CliRunner.invoke(cli.cli)
Merge the command in the same line
Directly monkeypatch the imported 'bma' module
---
 tests/test_verify_blocks.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tests/test_verify_blocks.py b/tests/test_verify_blocks.py
index d7d6d3fd..d11b510e 100644
--- a/tests/test_verify_blocks.py
+++ b/tests/test_verify_blocks.py
@@ -23,8 +23,8 @@ from duniterpy.api.client import Client
 from duniterpy.api import bma
 
 from silkaj.network_tools import EndPoint
+from silkaj import cli
 from silkaj.blocks import (
-    verify_blocks_signatures,
     check_passed_blocks_range,
     get_chunk_size,
     get_chunk,
@@ -51,7 +51,7 @@ async def current(self):
 )
 @pytest.mark.asyncio
 async def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypatch):
-    monkeypatch.setattr("duniterpy.api.bma.blockchain.current", current)
+    monkeypatch.setattr(bma.blockchain, "current", current)
     client = Client(EndPoint().BMA_ENDPOINT)
     # https://medium.com/python-pandemonium/testing-sys-exit-with-pytest-10c6e5f7726f
     with pytest.raises(SystemExit) as pytest_wrapped_e:
@@ -78,9 +78,8 @@ async def test_check_passed_blocks_range(from_block, to_block, capsys, monkeypat
     ],
 )
 def test_verify_blocks_signatures(from_block, to_block, monkeypatch):
-    monkeypatch.setattr("duniterpy.api.bma.blockchain.current", current)
-    blocks_range = [str(from_block), str(to_block)]
-    result = CliRunner().invoke(verify_blocks_signatures, blocks_range)
+    monkeypatch.setattr(bma.blockchain, "current", current)
+    result = CliRunner().invoke(cli.cli, ["verify", str(from_block), str(to_block)])
     assert result.exit_code == SUCCESS_EXIT_STATUS
     if to_block == 0:
         to_block = HEAD_BLOCK
-- 
GitLab