def configure_net_1_connection(): from moler.config import connections as conn_cfg conn_cfg.set_default_variant(io_type='memory', variant="threaded") conn_cfg.define_connection(name='net_1', io_type='memory') yield conn_cfg.clear()
def configure_net_1_connection(): import mock from moler.config import connections as conn_cfg with mock.patch.object(conn_cfg, "default_variant", {}): with mock.patch.object(conn_cfg, "named_connections", {}): conn_cfg.set_default_variant(io_type='memory', variant="threaded") conn_cfg.define_connection(name='net_1', io_type='memory') yield
def load_connection_from_config(config): if 'NAMED_CONNECTIONS' in config: for name, connection_specification in config[ 'NAMED_CONNECTIONS'].items(): io_type = connection_specification.pop("io_type") conn_cfg.define_connection(name, io_type, **connection_specification) if 'IO_TYPES' in config: if 'default_variant' in config['IO_TYPES']: defaults = config['IO_TYPES']['default_variant'] for io_type, variant in defaults.items(): conn_cfg.set_default_variant(io_type, variant)