generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: update ape version and add a test (#4)
- Loading branch information
1 parent
8063d80
commit a6bfd14
Showing
10 changed files
with
80 additions
and
22 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
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
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
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
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
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
File renamed without changes.
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,24 @@ | ||
import ape | ||
import pytest | ||
from ape._cli import cli as ape_cli | ||
from click.testing import CliRunner | ||
|
||
|
||
@pytest.fixture | ||
def networks(): | ||
return ape.networks | ||
|
||
|
||
@pytest.fixture | ||
def accounts(): | ||
return ape.accounts | ||
|
||
|
||
@pytest.fixture | ||
def runner(): | ||
return CliRunner() | ||
|
||
|
||
@pytest.fixture | ||
def cli(): | ||
return ape_cli |
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,34 @@ | ||
EXPECTED_OUTPUT = """ | ||
polygon | ||
├── mainnet | ||
│ └── geth (default) | ||
├── mumbai | ||
│ └── geth (default) | ||
└── local (default) | ||
└── test (default) | ||
""".strip() | ||
|
||
|
||
def assert_rich_text(actual: str, expected: str): | ||
""" | ||
The output from `rich` causes a bunch of extra spaces to | ||
appear at the end of each line. For easier testing, we remove those here. | ||
""" | ||
actual = f"polygon{actual.split('polygon')[-1]}" | ||
if "ethereum" in actual: | ||
actual = actual.split("ethereum")[0] | ||
|
||
expected = expected.strip() | ||
lines = actual.split("\n") | ||
new_lines = [] | ||
for line in lines: | ||
if line: | ||
new_lines.append(line.rstrip()) | ||
|
||
actual = "\n".join(new_lines) | ||
assert actual == expected | ||
|
||
|
||
def test_networks(runner, cli): | ||
result = runner.invoke(cli, ["networks", "list"]) | ||
assert_rich_text(result.output, EXPECTED_OUTPUT) |
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,7 @@ | ||
def test_use_provider(accounts, networks): | ||
with networks.fantom.local.use_provider("test"): | ||
account = accounts.test_accounts[0] | ||
receipt = account.transfer(account, 100) | ||
|
||
assert not receipt.failed | ||
assert receipt.value == 100 |