Beispiel #1
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.
    input_data = {
        'metadata': {
            'title': 'Test'
        },
    }
    service = RecordService(ServiceConfig)
    title_parts = [
        "The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"
    ]
    title_parts_len = len(title_parts)

    units = []
    for i in range(3):
        data = deepcopy(input_data)
        data["metadata"]["title"] = " ".join(title_parts[:title_parts_len -
                                                         3 * i])
        time.sleep(0.01)
        units += [service.create(identity_simple, data)]

    Record.index.refresh()

    return units
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 = RecordService(ServiceConfig)

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

    Record.index.refresh()
Beispiel #3
0
def app(app, record_service_config):
    """Application factory fixture."""
    class CustomRecordServiceConfig(record_service_config):
        """Custom record resource config."""

        item_route = CustomRecordResourceConfig.item_route
        list_route = CustomRecordResourceConfig.list_route

    resource = RecordResource(config=CustomRecordResourceConfig,
                              service=RecordService(CustomRecordServiceConfig))
    custom_bp = resource.as_blueprint("custom_resource")
    app.register_blueprint(custom_bp)
    yield app
Beispiel #4
0
def service_wrel(appctx):
    """Service instance for records with relations."""
    class ServiceConfig(ServiceConfigBase):
        """Record cls config."""
        record_cls = RecordWithRelations
        relations = {"records": ["metadata.inner_record"]}

        components = ServiceConfigBase.components + [RelationsComponent]

    service = RecordService(ServiceConfig)
    current_service_registry.register(service, "recordwithrelations")

    return service
Beispiel #5
0
def app_with_custom_permissions(app, record_service_config):
    """Application factory fixture."""
    class CustomRecordServiceConfig(record_service_config):
        """Custom RecordService configuration for tests."""

        permission_policy_cls = AdminCanCreatePermissionPolicy

    # NOTE: This overrides the previously registered endpoints
    custom_bp = RecordResource(
        config=CustomRecordResourceConfig,
        service=RecordService(
            config=CustomRecordServiceConfig)).as_blueprint("custom_resource")
    app.register_blueprint(custom_bp)
    yield app
Beispiel #6
0
def service(appctx):
    """Service instance."""
    class ServiceConfig(ServiceConfigBase):
        """Record cls config."""
        record_cls = Record

        components = ServiceConfigBase.components + [
            ChangeNotificationsComponent,
        ]

    service = RecordService(ServiceConfig)
    current_service_registry.register(service)

    return service
Beispiel #7
0
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 = RecordService(ServiceConfig)

    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()
Beispiel #8
0
def service():
    """Service with files instance."""
    return RecordService(ServiceWithFilesConfig)
Beispiel #9
0
def service():
    return RecordService(ServiceWithFilesConfig)
def service():
    """Record Resource."""
    return RecordService(ServiceConfig)
Beispiel #11
0
def service(appctx):
    """Service instance."""
    return RecordService(ServiceConfig)
def _record_service():
    """Create a record service."""
    return RecordService(config=CustomRecordServiceConfig)