Beispiel #1
0
def data_managers(request):
    """
    Generate a datamanager with a database session and register a cleanup handler.

    :param pyramid.request.Request request: The request this db session will
        be tied to.
    :returns: A dictionary containing different
        :class:`datamanagers <atramhasis.data.datamanagers.DataManager>`.
    """
    session = request.registry.dbmaker()
    skos_manager = SkosManager(session)
    conceptscheme_manager = ConceptSchemeManager(session)
    languages_manager = LanguagesManager(session)
    audit_manager = AuditManager(session)

    def cleanup(request):
        session.close()

    request.add_finished_callback(cleanup)

    return {
        'skos_manager': skos_manager,
        'conceptscheme_manager': conceptscheme_manager,
        'languages_manager': languages_manager,
        'audit_manager': audit_manager
    }
Beispiel #2
0
def data_managers(request):
    session_mock = Mock()
    session_mock.query = Mock(side_effect=create_query_mock)
    skos_manager = SkosManager(session_mock)
    conceptscheme_manager = ConceptSchemeManager(session_mock)
    audit_manager = AuditManager(session_mock)
    return {
        'skos_manager': skos_manager,
        'conceptscheme_manager': conceptscheme_manager,
        'audit_manager': audit_manager
    }
 def setUp(self):
     super(AuditManagerTest, self).setUp()
     self.audit_manager = AuditManager(self.session_maker())