2021-02-01 18:12:51 +01:00
|
|
|
# standard imports
|
|
|
|
import os
|
|
|
|
import sys
|
2021-03-29 15:27:53 +02:00
|
|
|
import logging
|
2021-05-31 17:34:16 +02:00
|
|
|
import uuid
|
2021-02-01 18:12:51 +01:00
|
|
|
|
2021-04-24 19:49:21 +02:00
|
|
|
# external imports
|
2021-07-05 10:29:33 +02:00
|
|
|
import pytest
|
2021-05-19 17:11:08 +02:00
|
|
|
from eth_erc20 import ERC20
|
2021-05-31 17:34:16 +02:00
|
|
|
import redis
|
2021-04-24 19:49:21 +02:00
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
# local imports
|
|
|
|
from cic_eth.api import Api
|
2021-04-24 19:49:21 +02:00
|
|
|
from cic_eth.task import BaseTask
|
2021-02-01 18:12:51 +01:00
|
|
|
|
|
|
|
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
root_dir = os.path.dirname(script_dir)
|
|
|
|
sys.path.insert(0, root_dir)
|
|
|
|
|
2021-03-29 15:27:53 +02:00
|
|
|
# assemble fixtures
|
2021-06-30 20:15:40 +02:00
|
|
|
from cic_eth.pytest.fixtures_config import *
|
|
|
|
from cic_eth.pytest.fixtures_celery import *
|
|
|
|
from cic_eth.pytest.fixtures_database import *
|
|
|
|
from cic_eth.pytest.fixtures_role import *
|
|
|
|
from cic_eth.pytest.fixtures_contract import *
|
2021-07-05 10:29:33 +02:00
|
|
|
from cic_eth.pytest.fixtures_token import *
|
2021-03-29 15:27:53 +02:00
|
|
|
from chainlib.eth.pytest import *
|
|
|
|
from eth_contract_registry.pytest import *
|
|
|
|
from cic_eth_registry.pytest.fixtures_contracts import *
|
|
|
|
from cic_eth_registry.pytest.fixtures_tokens import *
|
2021-02-01 18:12:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
2021-03-29 15:27:53 +02:00
|
|
|
def api(
|
|
|
|
default_chain_spec,
|
|
|
|
custodial_roles,
|
|
|
|
):
|
|
|
|
chain_str = str(default_chain_spec)
|
|
|
|
return Api(chain_str, queue=None, callback_param='foo')
|
2021-04-24 19:49:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
@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
|
2021-05-31 17:34:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
|
|
def have_redis(
|
|
|
|
config,
|
|
|
|
):
|
|
|
|
|
|
|
|
r = redis.Redis(
|
|
|
|
host = config.get('REDIS_HOST'),
|
|
|
|
port = config.get('REDIS_PORT'),
|
|
|
|
db = config.get('REDIS_DB'),
|
|
|
|
)
|
|
|
|
k = str(uuid.uuid4())
|
|
|
|
try:
|
|
|
|
r.set(k, 'foo')
|
|
|
|
r.delete(k)
|
|
|
|
except redis.exceptions.ConnectionError as e:
|
|
|
|
return e
|
|
|
|
except TypeError as e:
|
|
|
|
return e
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|