Add test for default token task
This commit is contained in:
parent
5d96ed5e24
commit
3ed263a879
@ -3,8 +3,12 @@ import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
# external imports
|
||||
from chainlib.eth.erc20 import ERC20
|
||||
|
||||
# local imports
|
||||
from cic_eth.api import Api
|
||||
from cic_eth.task import BaseTask
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
root_dir = os.path.dirname(script_dir)
|
||||
@ -28,3 +32,26 @@ def api(
|
||||
):
|
||||
chain_str = str(default_chain_spec)
|
||||
return Api(chain_str, queue=None, callback_param='foo')
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def foo_token_symbol(
|
||||
default_chain_spec,
|
||||
foo_token,
|
||||
eth_rpc,
|
||||
contract_roles,
|
||||
):
|
||||
|
||||
c = ERC20(default_chain_spec)
|
||||
o = c.symbol(foo_token, sender_address=contract_roles['CONTRACT_DEPLOYER'])
|
||||
r = eth_rpc.do(o)
|
||||
return c.parse_symbol(r)
|
||||
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def default_token(
|
||||
foo_token,
|
||||
foo_token_symbol,
|
||||
):
|
||||
BaseTask.default_token_symbol = foo_token_symbol
|
||||
BaseTask.default_token_address = foo_token
|
||||
|
@ -34,6 +34,7 @@ def celery_includes():
|
||||
'cic_eth.admin.ctrl',
|
||||
'cic_eth.admin.nonce',
|
||||
'cic_eth.admin.debug',
|
||||
'cic_eth.admin.token',
|
||||
'cic_eth.eth.account',
|
||||
'cic_eth.callbacks.noop',
|
||||
'cic_eth.callbacks.http',
|
||||
|
21
apps/cic-eth/tests/unit/admin/test_default_token.py
Normal file
21
apps/cic-eth/tests/unit/admin/test_default_token.py
Normal file
@ -0,0 +1,21 @@
|
||||
# external imports
|
||||
import celery
|
||||
|
||||
|
||||
def test_default_token(
|
||||
default_token,
|
||||
celery_session_worker,
|
||||
foo_token,
|
||||
foo_token_symbol,
|
||||
):
|
||||
|
||||
s = celery.signature(
|
||||
'cic_eth.admin.token.default_token',
|
||||
[],
|
||||
queue=None,
|
||||
)
|
||||
t = s.apply_async()
|
||||
r = t.get()
|
||||
|
||||
assert r['address'] == foo_token
|
||||
assert r['symbol'] == foo_token_symbol
|
Loading…
Reference in New Issue
Block a user