Пример #1
0
    def init_app(self, _app, db=None):
        self.init_config(_app)
        _state = InvenioRecordsDraftState(_app)
        _app.extensions['invenio-records-draft'] = _state

        def app_loaded_callback(sender, app, **kwargs):
            if _app == app:
                _state.app_loaded(app)

        app_loaded.connect(app_loaded_callback, weak=False)
Пример #2
0
    def init_app(self, _app):
        """Flask application initialization."""
        self.init_config(_app)
        _state = _OARepoFSMState(_app)
        _app.extensions['oarepo-fsm'] = _state

        def app_loaded_callback(sender, app, **kwargs):
            if _app == app:
                _state.app_loaded(app)

        app_loaded.connect(app_loaded_callback, weak=False)
Пример #3
0
def test_create_app_factory():
    """Test signals sending."""
    calls = {'created': 0, 'loaded': 0}
    create_app = create_app_factory('test')

    def _receiver(name):
        def _inner(sender, app=None):
            calls[name] += 1
            calls['{}_app'.format(name)] = app
        return _inner

    app_created.connect(_receiver('created'), sender=create_app, weak=False)
    app_loaded.connect(_receiver('loaded'), sender=create_app, weak=False)

    assert callable(create_app)

    app = create_app()
    assert calls['created'] == 1
    assert calls['loaded'] == 1
    assert calls['created_app'] is app
    assert calls['loaded_app'] is app
Пример #4
0
def test_create_app_factory():
    """Test signals sending."""
    calls = {"created": 0, "loaded": 0}
    create_app = create_app_factory("test")

    def _receiver(name):
        def _inner(sender, app=None):
            calls[name] += 1
            calls[f"{name}_app"] = app

        return _inner

    app_created.connect(_receiver("created"), sender=create_app, weak=False)
    app_loaded.connect(_receiver("loaded"), sender=create_app, weak=False)

    assert callable(create_app)

    app = create_app()
    assert calls["created"] == 1
    assert calls["loaded"] == 1
    assert calls["created_app"] is app
    assert calls["loaded_app"] is app
Пример #5
0
 def init_app(self, app):
     self.init_config(app)
     _state = RecordsDraftState(app)
     app.extensions['oarepo-draft'] = _state
     app_loaded.connect(_state.app_loaded)
Пример #6
0
 def init_app(self, app):
     self.init_config(app)
     app.extensions['oarepo-mapping-includes'] = OARepoMappingIncludesState(
         app)
     app_loaded.connect(mapping_transformer)
Пример #7
0
    def init_app(self, app):
        """Flask application initialization."""

        app.extensions['testinvenio-oarepo_actions'] = self
        app_loaded.connect(action_urls)