Skip to content

Commit

Permalink
chore: update ape version and add a test (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotPeopling2day authored Jul 27, 2022
1 parent 8063d80 commit a6bfd14
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # eventually add `windows-latest`
python-version: [3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9, '3.10']

steps:
- uses: actions/checkout@v2
Expand Down
15 changes: 5 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.2.0
hooks:
- id: check-yaml

- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
hooks:
- id: seed-isort-config

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.9.3
rev: v5.10.1
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 21.10b0
rev: 22.6.0
hooks:
- id: black
name: black

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
rev: 4.0.1
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
rev: v0.971
hooks:
- id: mypy
additional_dependencies: [types-PyYAML, types-requests]
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source venv/bin/activate
python setup.py install

# install the developer dependencies (-e is interactive mode)
pip install -e .[dev]
pip install -e .'[dev]'
```

## Pre-Commit Hooks
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Ecosystem Plugin for Polygon support in Ape

## Dependencies

* [python3](https://www.python.org/downloads) version 3.7 or greater, python3-dev
* [python3](https://www.python.org/downloads) version 3.7.2 or greater, python3-dev

## Installation

Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ write_to = "ape_polygon/version.py"

[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39']
target-version = ['py37', 'py38', 'py39', 'py310']
include = '\.pyi?$'

[tool.pytest.ini_options]
Expand All @@ -35,7 +35,5 @@ markers = "fuzzing: Run Hypothesis fuzz test suite"
line_length = 100
force_grid_wrap = 0
include_trailing_comma = true
known_third_party = ["ape", "ape_ethereum", "ape_geth", "ape_test", "setuptools"]
known_first_party = ["ape_polygon"]
multi_line_output = 3
use_parentheses = true
12 changes: 6 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
],
"lint": [
"black>=22.3.0,<23.0", # auto-formatter and linter
"mypy>=0.910,<1.0", # Static type analyzer
"flake8>=3.8.3,<4.0", # Style linter
"black>=22.6.0,<23.0", # auto-formatter and linter
"mypy>=0.971,<1.0", # Static type analyzer
"flake8>=4.0.1,<5.0", # Style linter
"isort>=5.10.1,<6.0", # Import sorting linter
],
"release": [ # `release` GitHub Action job uses this
Expand Down Expand Up @@ -54,9 +54,9 @@
include_package_data=True,
install_requires=[
"importlib-metadata ; python_version<'3.8'",
"eth-ape>=0.3.0,<0.4.0",
], # NOTE: Add 3rd party libraries here
python_requires=">=3.7.2,<3.11",
"eth-ape>=0.4.0,<0.5.0",
],
python_requires=">=3.7.2,<4",
extras_require=extras_require,
py_modules=["ape_polygon"],
license="Apache-2.0",
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions tests/conftest.py
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
34 changes: 34 additions & 0 deletions tests/test_integration.py
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)
7 changes: 7 additions & 0 deletions tests/test_provider.py
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

0 comments on commit a6bfd14

Please sign in to comment.