def add_initial_content(libres_registry, session_manager, town_name, form_definitions=None): """ Adds the initial content for the given town on the given session. All content that comes with a new town is added here. Note, the ``form_definitions`` parameter is used to speed up testing, you usually do not want to specify it. """ session = session_manager.session() libres_context = LibresIntegration.libres_context_from_session_manager( libres_registry, session_manager) # can only be called if no town is defined yet assert not session.query(Town).first() session.add(Town(name=town_name)) add_root_pages(session) add_builtin_forms(session, form_definitions) add_resources(libres_context) add_events(session) session.flush()
def libres_context(session_manager): session_manager.bases.append(ORMBase) session_manager.set_current_schema('test_' + uuid4().hex) registry = create_default_registry() yield LibresIntegration.libres_context_from_session_manager( registry, session_manager)
def libres_context(session_manager): session_manager.bases.append(ORMBase) session_manager.set_current_schema('test_' + uuid4().hex) registry = create_default_registry() yield LibresIntegration.libres_context_from_session_manager( registry, session_manager )