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