async def test_get_index_data_with_accessors(dummy_request): request = dummy_request # noqa container = await create_content('Container', id='guillotina', title='Guillotina') container.__name__ = 'guillotina' ob = await create_content('Example', id='foobar', categories=[{ 'label': 'foo', 'number': 1 }]) data = ICatalogDataAdapter(ob) fields = await data() for field_name in ('categories_accessor', 'foobar_accessor', 'type_name', 'categories', 'uuid', 'path', 'title', 'tid'): assert field_name in fields # now only with indexes specified data = ICatalogDataAdapter(ob) fields = await data(indexes=['categories']) # but should also pull in `foobar_accessor` because it does not # have a field specified for it. for field_name in ('categories_accessor', 'foobar_accessor', 'type_name', 'categories', 'uuid', 'tid'): assert field_name in fields assert 'title' not in fields
async def test_override_index_directive(dummy_txn_root): container = await create_content("Container", id="guillotina", title="Guillotina") container.__name__ = "guillotina" ob = await create_content("CustomItem", id="foobar", title="Test") data = ICatalogDataAdapter(ob) fields = await data() assert fields[ "title"] == "The title is: Test" # Good, uses the custom accessor ob = await create_content("Item", id="foobar", title="Test") data = ICatalogDataAdapter(ob) fields = await data(indexes=["title"]) assert fields["title"] == "Test"
async def test_get_index_data_with_accessors(dummy_txn_root): async with dummy_txn_root: container = await create_content("Container", id="guillotina", title="Guillotina") container.__name__ = "guillotina" ob = await create_content("Example", id="foobar", categories=[{ "label": "foo", "number": 1 }]) data = ICatalogDataAdapter(ob) fields = await data() for field_name in ( "categories_accessor", "foobar_accessor", "type_name", "categories", "uuid", "path", "title", "tid", ): assert field_name in fields # now only with indexes specified data = ICatalogDataAdapter(ob) fields = await data(indexes=["categories"]) # but should also pull in `foobar_accessor` because it does not # have a field specified for it. for field_name in ( "categories_accessor", "foobar_accessor", "type_name", "categories", "uuid", "tid", ): assert field_name in fields assert "title" not in fields
async def test_get_index_data(dummy_txn_root): async with dummy_txn_root: container = await create_content("Container", id="guillotina", title="Guillotina") container.__name__ = "guillotina" ob = await create_content("Item", id="foobar") data = ICatalogDataAdapter(ob) fields = await data() assert "type_name" in fields assert "uuid" in fields assert "path" in fields assert "title" in fields
async def test_get_index_data(dummy_request): request = dummy_request # noqa container = await create_content('Container', id='guillotina', title='Guillotina') container.__name__ = 'guillotina' ob = await create_content('Item', id='foobar') data = ICatalogDataAdapter(ob) fields = await data() assert 'type_name' in fields assert 'uuid' in fields assert 'path' in fields assert 'title' in fields
async def test_get_index_data(self, dummy_request): self.request = dummy_request site = await create_content('Site', id='guillotina', title='Guillotina') site.__name__ = 'guillotina' ob = await create_content('Item', id='foobar') data = ICatalogDataAdapter(ob) fields = await data() assert 'portal_type' in fields assert 'uuid' in fields assert 'path' in fields assert 'title' in fields