-
Notifications
You must be signed in to change notification settings - Fork 382
Expand file tree
/
Copy pathtest_cli.py
More file actions
51 lines (36 loc) · 1.24 KB
/
test_cli.py
File metadata and controls
51 lines (36 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import sys
import pytest
from click.testing import CliRunner
from uniswap.cli import main
def print_result(result):
print(result)
print(result.stdout.strip())
print(result.stderr.strip(), file=sys.stderr)
def test_get_price():
runner = CliRunner(mix_stderr=False)
result = runner.invoke(main, ["price", "eth", "dai"])
print_result(result)
assert result.exit_code == 0
# Will break when ETH breaks 10k
assert 1000 < float(result.stdout) < 10_000
def test_get_price_stables():
"""Tests that decimals are handled correctly."""
if os.getenv("UNISWAP_VERSION") == "1":
pytest.skip("Not supported in v1")
runner = CliRunner(mix_stderr=False)
result = runner.invoke(main, ["price", "dai", "usdc"])
print_result(result)
assert result.exit_code == 0
# Will break if peg is lost
assert 0.9 < float(result.stdout) < 1.1
def test_get_token():
runner = CliRunner(mix_stderr=False)
result = runner.invoke(main, ["token", "weth"])
print_result(result)
assert result.exit_code == 0
def test_get_tokendb():
runner = CliRunner(mix_stderr=False)
result = runner.invoke(main, ["tokendb", "--metadata"])
print_result(result)
assert result.exit_code == 0