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

Adapt tests to rich_click usage (#466)

Adapt click UI changes error report tests
Adapt tests with patched click
parent 0eb1a537
No related branches found
No related tags found
1 merge request!241Use rich_click (#466)
This commit is part of merge request !241. Comments created here will be created in the context of that merge request.
......@@ -126,6 +126,7 @@ def test_transaction_amount_errors(
TRANSFER = ["money", "transfer"]
MUTUALLY_EXCLUSIVE = "is mutually exclusive with arguments"
def test_tx_passed_amount_cli():
......@@ -144,22 +145,22 @@ def test_tx_passed_amount_cli():
# Multiple options
result = CliRunner().invoke(cli, [*TRANSFER, "--amount", 1, "--amountUD", 1])
assert "Error: Usage" in result.output
assert MUTUALLY_EXCLUSIVE in result.output
assert result.exit_code == 2
result = CliRunner().invoke(cli, [*TRANSFER, "--amount", 1, "--allSources"])
assert "Error: Usage" in result.output
assert MUTUALLY_EXCLUSIVE in result.output
assert result.exit_code == 2
result = CliRunner().invoke(cli, [*TRANSFER, "--amountUD", 1, "--allSources"])
assert "Error: Usage" in result.output
assert MUTUALLY_EXCLUSIVE in result.output
assert result.exit_code == 2
result = CliRunner().invoke(
cli,
[*TRANSFER, "--amount", 1, "--amountUD", 1, "--allSources"],
)
assert "Error: Usage" in result.output
assert MUTUALLY_EXCLUSIVE in result.output
assert result.exit_code == 2
result = CliRunner().invoke(cli, [*TRANSFER, "-r", "A"])
......@@ -177,14 +178,14 @@ def test_tx_passed_amount_cli():
cli,
[*TRANSFER, "-r", "A", "-a", MINIMAL_ABSOLUTE_TX_AMOUNT - 0.001],
)
assert "Error: Invalid value for '--amount'" in result.output
assert "Invalid value for '--amount'" in result.output
assert result.exit_code == 2
result = CliRunner().invoke(
cli,
[*TRANSFER, "-r", "A", "-d", MINIMAL_RELATIVE_TX_AMOUNT - 1e-07],
)
assert "Error: Invalid value for '--amountUD'" in result.output
assert "Invalid value for '--amountUD'" in result.output
assert result.exit_code == 2
result = CliRunner().invoke(cli, [*TRANSFER, "-r", "A", "-a", 1, "-a", 2])
......
......@@ -38,7 +38,7 @@ def test_license_approval_g1_test(capsys):
(False, False),
],
)
@patch("click.confirm")
@patch("rich_click.confirm")
@patch.object(gml.G1MonetaryLicense, "display_license")
def test_license_approval_g1(mock_display_license, mock_confirm, display, approve):
# https://stackoverflow.com/a/62939130
......
......@@ -17,8 +17,8 @@ import urllib
from pathlib import Path
from unittest.mock import Mock
import click
import pytest
import rich_click as click
from click.testing import CliRunner
from duniterpy.api import bma
from duniterpy.documents.revocation import Revocation
......
......@@ -13,8 +13,8 @@
# You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import click
import pytest
import rich_click as click
from silkaj.wot import tools as w_tools
......
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