"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/local.py $
$Id: local.py 27988 2006-02-17 22:29:13Z rmasse $
"""
from dulcinea.param.parameter_type import ParameterDatabase
from dulcinea.physical_unit import UnitCollection
from dulcinea.inquiry import InquiryDatabase
from dulcinea.link_triple import LinkTripleDatabase
from dulcinea.material import MaterialDatabase, Material
from dulcinea.persistent_session import DulcineaSessionManager
from dulcinea.user import DulcineaUserDatabase
from durus.storage import MemoryStorage
from durus.connection import Connection


def make_test_connection():
    connection = Connection(MemoryStorage())
    connection.get_root().update(dict(
        parameter_db=ParameterDatabase(),
        material_db=MaterialDatabase(),
        standard_units=UnitCollection(),
        link_triple_db=LinkTripleDatabase(),
        user_db=DulcineaUserDatabase(),
        inquiry_db=InquiryDatabase(),
        session_manager=DulcineaSessionManager()))
    mdb = connection.get_root()['material_db']
    mdb.add_material(Material('gold'))
    mdb.add_material(Material('aluminum'))
    mdb.add_material(Material('silver'))
    mdb.add_material(Material('boron'))
    mdb.add_material(Material('silicon'))
    mdb.add_material(Material('blah'))
    connection.commit()
    return connection
