def test_from_env(): ctx = context.from_env() assert ctx.config is not None assert ctx.jsonrpc_client is not None assert ctx.custody is not None
def test_raise_value_error_for_no_vasp_compliance_key(): ctx = context.from_env() account = testnet.Faucet(ctx.jsonrpc_client).gen_account() with pytest.raises(ValueError): ctx.get_vasp_public_compliance_key(account.account_address)
def test_get_set(): ctx = context.from_env() context.set(ctx) assert context.get() == ctx
# Copyright (c) The Diem Core Contributors # SPDX-License-Identifier: Apache-2.0 import context from offchain import offchain_service offchain_service.bootstrap(context.from_env())
def env_context() -> typing.Generator[typing.Any, None, None]: context.set(context.from_env()) yield context.set(None)
def _init_context(): context.set(context.from_env())
ADMIN_LOGIN_ENABLED: bool = ( True if os.getenv("ADMIN_LOGIN_ENABLED") is not None else False ) SECRET_KEY: str = os.getenv("SECRET_KEY", "you-will-never-guess") SESSION_TYPE: str = "redis" # init redis and dramatiq broker def setup_redis_broker() -> None: _connection_pool: redis.BlockingConnectionPool = redis.BlockingConnectionPool( host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, password=REDIS_PASSWORD ) _redis_db: redis.StrictRedis = redis.StrictRedis(connection_pool=_connection_pool) _result_backend = RedisBackend(encoder=PickleEncoder(), client=_redis_db) _result_middleware = Results(backend=_result_backend) broker: Broker = RedisBroker( connection_pool=_connection_pool, middleware=[_result_middleware], namespace="lrw", ) dramatiq.set_broker(broker) dramatiq.set_encoder(dramatiq.PickleEncoder()) if dramatiq.broker.global_broker is None: if "VASP_ADDR" in os.environ: context.set(context.from_env()) setup_redis_broker()