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)), }
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()
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))
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()
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())
def search_options(app): service = Service() options = service.config.search_pagination_options return options
def record_resource(): """Record Resource.""" return CustomRecordResource(config=CustomRecordResourceConfig, service=Service(config=FileServiceConfig))