Пример #1
0
def file_resources():
    """File Resources."""
    return {
        'mock_file':
        CustomFileResource(config=CustomFileResourceConfig,
                           service=Service(config=FileServiceConfig)),
        'mock_file_action':
        CustomFileActionResource(config=CustomFileActionResourceConfig,
                                 service=Service(config=FileServiceConfig)),
    }
Пример #2
0
def three_indexed_records(app, identity_simple, es):
    # NOTE: We make use of es fixture (and not es_clear) here because all tests
    #       assume 3 records have been indexed and NO tests in this module
    #       adds/deletes any.
    service = Service()

    for i in range(3):
        data = {
            'metadata': {
                'title': f"Test foo {i}",
            },
        }
        service.create(identity_simple, data)

    Record.index.refresh()
Пример #3
0
def resource():
    """Resource."""
    # This should work but doesn't because the application context is checked
    # to see if it's been overridden in the config.
    # return Resource(service=Service())
    return Resource(config=ResourceConfig,
                    service=Service(config=ServiceConfig))
Пример #4
0
def spy_resource():
    class SpyResourceConfig(CustomRecordResourceConfig):
        """Same as Resource except a different list route to not clash."""

        list_route = "/preference-mocks"

    class SpyResource(CustomRecordResource):
        """Same as Resource except that it logs preference."""
        def _get_es_preference(self):
            self.exposed_preference = super()._get_es_preference()
            return self.exposed_preference

    # NOTE: Because this fixture is module scoped, only 1 SpyResource exists
    return SpyResource(config=SpyResourceConfig,
                       service=Service(config=ServiceConfig))
def three_indexed_records(app, identity_simple, es):
    # NOTE: es is used (and not es_clear) here because all tests
    #       assume 3 records have been indexed and NO tests in this module
    #       adds/deletes any.
    service = Service()

    def _create(metadata):
        data = {
            'metadata': {
                'title': 'Test',
                **metadata
            },
        }
        service.create(identity_simple, data)

    _create({"title": "Record 1", "type": {"type": "A", "subtype": "AA"}})
    _create({"title": "Record 2", "type": {"type": "A", "subtype": "AB"}})
    _create({"title": "Record 3", "type": {"type": "B"}})

    Record.index.refresh()
Пример #6
0
def service(appctx):
    """Service instance."""
    return Service()
def draft_file_action_resource():
    """Draft file action resource."""
    return DraftFileActionResource(service=Service())
def draft_file_resource():
    """Draft file resource."""
    return DraftFileResource(service=Service())
def version_resource():
    """Draft version Resource."""
    return DraftVersionResource(service=Service())
def draft_action_resource():
    """Draft action resource."""
    return DraftActionResource(service=Service())
def draft_resource():
    """Draft resource."""
    return DraftResource(service=Service())
def record_file_action_resource():
    """Record file action resource."""
    return RecordFileActionResource(service=Service())
def record_file_resource():
    """Record file resource."""
    return RecordFileResource(service=Service())
def record_resource():
    """Record resource."""
    return RecordResource(service=Service())
Пример #15
0
def search_options(app):
    service = Service()
    options = service.config.search_pagination_options
    return options
Пример #16
0
def record_resource():
    """Record Resource."""
    return CustomRecordResource(config=CustomRecordResourceConfig,
                                service=Service(config=FileServiceConfig))