-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: add dataclassy as dependency * refactor: upgrade to dataclassy and other small improvements * refactor: create manager object instead of working with globals * test: add integration tests * feat: add ability to print and search tokens. clean up output * fix: forgot click dependency
- Loading branch information
Showing
10 changed files
with
247 additions
and
128 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
File renamed without changes.
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,20 @@ | ||
from pathlib import Path | ||
|
||
import pytest # type: ignore | ||
from click.testing import CliRunner | ||
|
||
from tokenlists import TokenListManager, _cli | ||
|
||
|
||
@pytest.fixture | ||
def runner(monkeypatch): | ||
runner = CliRunner() | ||
with runner.isolated_filesystem() as temp_dir: | ||
monkeypatch.setattr(_cli, "TokenListManager", lambda: TokenListManager(Path(temp_dir))) | ||
yield runner | ||
|
||
|
||
@pytest.fixture | ||
def cli(runner): | ||
# NOTE: Depends on `runner` fixture for config side effects | ||
yield _cli.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,37 @@ | ||
TEST_URI = "tokens.1inch.eth" | ||
|
||
|
||
def test_empty_list(runner, cli): | ||
result = runner.invoke(cli, ["list"]) | ||
assert result.exit_code == 0 | ||
assert "No tokenlists exist" in result.output | ||
|
||
|
||
def test_install(runner, cli): | ||
result = runner.invoke(cli, ["list"]) | ||
assert result.exit_code == 0 | ||
assert "No tokenlists exist" in result.output | ||
|
||
result = runner.invoke(cli, ["install", TEST_URI]) | ||
assert result.exit_code == 0 | ||
|
||
result = runner.invoke(cli, ["list"]) | ||
assert result.exit_code == 0 | ||
assert "1inch" in result.output | ||
|
||
|
||
def test_remove(runner, cli): | ||
result = runner.invoke(cli, ["install", TEST_URI]) | ||
assert result.exit_code == 0 | ||
|
||
result = runner.invoke(cli, ["list"]) | ||
assert result.exit_code == 0 | ||
assert "1inch" in result.output | ||
|
||
result = runner.invoke(cli, ["remove", "1inch"]) | ||
assert result.exit_code == 0 | ||
assert result.exit_code == 0 | ||
|
||
result = runner.invoke(cli, ["list"]) | ||
assert result.exit_code == 0 | ||
assert "No tokenlists exist" in result.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 |
---|---|---|
@@ -1,20 +1,8 @@ | ||
from .manager import ( | ||
available_token_lists, | ||
default_token_list, | ||
get_token_info, | ||
get_token_list, | ||
install_token_list, | ||
set_default_token_list, | ||
) | ||
from .manager import TokenListManager | ||
from .typing import TokenInfo, TokenList | ||
|
||
__all__ = [ | ||
"TokenInfo", | ||
"TokenList", | ||
"install_token_list", | ||
"set_default_token_list", | ||
"available_token_lists", | ||
"default_token_list", | ||
"get_token_info", | ||
"get_token_list", | ||
"TokenListManager", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
DATA_FOLDER = Path.home().joinpath(".tokenlists") | ||
DEFAULT_TOKEN_LIST: Optional[str] = None | ||
DEFAULT_CACHE_PATH = Path.home().joinpath(".tokenlists") | ||
DEFAULT_TOKENLIST: Optional[str] = None | ||
|
||
UNISWAP_ENS_TOKENLISTS_HOST = "https://wispy-bird-88a7.uniswap.workers.dev/?url=http://{}.link" |
Oops, something went wrong.