-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paweł Nowosielski
committed
Apr 7, 2021
1 parent
4e79f92
commit c671b93
Showing
2 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
test/yagna/module/payments/test_payment_driver_list_cmd.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"""Tests payment driver list CLI command.""" | ||
|
||
import logging | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import pytest | ||
|
||
from goth.address import ( | ||
PROXY_HOST, | ||
YAGNA_REST_URL, | ||
) | ||
from goth.node import node_environment | ||
from goth.runner import Runner | ||
from goth.runner.container.payment import PaymentIdPool | ||
from goth.runner.container.yagna import YagnaContainerConfig | ||
from goth.runner.probe import RequestorProbe | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def _topology(payment_id_pool: PaymentIdPool) -> List[YagnaContainerConfig]: | ||
# Nodes are configured to communicate via proxy | ||
|
||
requestor_env = node_environment( | ||
rest_api_url_base=YAGNA_REST_URL.substitute(host=PROXY_HOST), | ||
) | ||
|
||
return [ | ||
YagnaContainerConfig( | ||
name="requestor", | ||
probe_type=RequestorProbe, | ||
environment=requestor_env, | ||
payment_id=payment_id_pool.get_id(), | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_payment_driver_list( | ||
assets_path: Path, | ||
demand_constraints: str, | ||
payment_id_pool: PaymentIdPool, | ||
runner: Runner, | ||
task_package_template: str, | ||
): | ||
"""Test just the requestor's CLI command, no need to setup provider.""" | ||
|
||
topology = _topology(payment_id_pool) | ||
|
||
async with runner(topology): | ||
requestor = runner.get_probes(probe_type=RequestorProbe)[0] | ||
|
||
res = requestor.cli.payment_drivers() | ||
assert res and res.items() | ||
driver = next(iter(res.values()), None) | ||
|
||
assert driver.default_network, "Default network should be set" | ||
|
||
network = driver.networks.get(driver.default_network, None) | ||
assert network, "Network should belong to the Driver" | ||
assert network.default_token, "Default taken should be set" | ||
|
||
token = network.tokens.get(network.default_token, None) | ||
assert token, "Token should belong to the Network" |