Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c90962e

Browse files
Merge pull request #33 from AndreMiras/feature/core_unittest_module_and_linter
Uses core unittest module and introduces linter
2 parents 7161d40 + f3cd702 commit c90962e

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

‎tests/test_proxies.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
import re
2+
import unittest
23

4+
from etherscan.client import EmptyResponse
35
from etherscan.proxies import Proxies
46

57
API_KEY = 'YourAPIkey'
68

79

8-
def test_get_most_recent_block():
9-
api = Proxies(api_key=API_KEY)
10-
most_recent = int(api.get_most_recent_block(), 16)
11-
print(most_recent)
12-
p = re.compile('^[0-9]{7}$')
13-
assert (p.match(str(most_recent)))
10+
class ProxiesTestCase(unittest.TestCase):
11+
12+
def test_get_most_recent_block(self):
13+
api = Proxies(api_key=API_KEY)
14+
# currently raises an exception even though it should not, see:
15+
# https://github.com/corpetty/py-etherscan-api/issues/32
16+
with self.assertRaises(EmptyResponse):
17+
most_recent = int(api.get_most_recent_block(), 16)
18+
print(most_recent)
19+
p = re.compile('^[0-9]{7}$')
20+
self.assertTrue(p.match(str(most_recent)))

‎tests/test_token.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import pytest
2-
3-
from etherscan.tokens import Tokens
4-
5-
ELCOIN_TOKEN_SUPPLY = '21265524714464'
6-
ELCOIN_TOKEN_BALANCE = "135499"
7-
AP_IKEY = 'YourAPIkey'
8-
CONTRACT_ADDRESS = '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
9-
ADDRESS = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
10-
API_KEY = 'YourAPIkey'
11-
12-
def test_get_token_supply():
13-
api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=(API_KEY))
14-
assert (api.get_total_supply() == ELCOIN_TOKEN_SUPPLY)
15-
16-
def test_get_token_balance():
17-
api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=API_KEY)
18-
assert(api.get_token_balance(ADDRESS) == ELCOIN_TOKEN_BALANCE)
1+
import unittest
2+
3+
from etherscan.tokens import Tokens
4+
5+
ELCOIN_TOKEN_SUPPLY = '21265524714464'
6+
ELCOIN_TOKEN_BALANCE = "135499"
7+
CONTRACT_ADDRESS = '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
8+
ADDRESS = '0xe04f27eb70e025b78871a2ad7eabe85e61212761'
9+
API_KEY = 'YourAPIkey'
10+
11+
12+
class ProxiesTestCase(unittest.TestCase):
13+
14+
def test_get_token_supply(self):
15+
api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=(API_KEY))
16+
self.assertEqual(api.get_total_supply(), ELCOIN_TOKEN_SUPPLY)
17+
18+
def test_get_token_balance(self):
19+
api = Tokens(contract_address=CONTRACT_ADDRESS, api_key=API_KEY)
20+
self.assertEqual(api.get_token_balance(ADDRESS), ELCOIN_TOKEN_BALANCE)

‎tox.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
[tox]
2-
envlist = py27,py3
2+
envlist = pep8,py27,py3
33

44
[testenv]
55
deps =
66
pytest
77
-r{toxinidir}/pip-requirements.txt
88
commands =
99
python -m unittest discover --start-directory=tests/
10+
11+
[testenv:pep8]
12+
deps = flake8
13+
commands = flake8 tests/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /