Skip to content
Snippets Groups Projects
Commit d8e36c13 authored by Moul's avatar Moul
Browse files

[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
parent b58e3672
No related branches found
No related tags found
2 merge requests!146Merge dev into master branch to complete v0.8.0 development cycle,!137Code changes
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment