async def test_parse_base(): from guillotina.catalog.parser import BaseParser content = test_utils.create_content(Container) parser = BaseParser(None, content) result = parser({ "_from": 5, "_sort_asc": "modification_date", "path__starts": "foo/bar" }) assert result["_from"] == 5 assert result["sort_on"] == "modification_date" assert result["sort_dir"] == "ASC" assert result["params"]["path__starts"] == "/foo/bar" result = parser({"_sort_des": "modification_date"}) assert result["sort_on"] == "modification_date" assert result["sort_dir"] == "DESC" result = parser({"_metadata": "modification_date"}) result["metadata"] == ["modification_date"] result = parser({"_metadata": "_all"}) result["metadata"] is None result = parser({"_metadata_not": "modification_date"}) result["excluded_metadata"] == ["modification_date"]
async def test_parse_base(): from guillotina.catalog.parser import BaseParser content = test_utils.create_content(Container) parser = BaseParser(None, content) result = parser({ '_from': 5, '_sort_asc': 'modification_date', 'path__starts': 'foo/bar' }) assert result['_from'] == 5 assert result['sort_on'] == 'modification_date' assert result['sort_dir'] == 'ASC' assert result['params']['path__starts'] == '/foo/bar' result = parser({'_sort_des': 'modification_date'}) assert result['sort_on'] == 'modification_date' assert result['sort_dir'] == 'DESC' result = parser({'_metadata': 'modification_date'}) result['metadata'] == ['modification_date'] result = parser({'_metadata': '_all'}) result['metadata'] is None result = parser({'_metadata_not': 'modification_date'}) result['excluded_metadata'] == ['modification_date']
async def test_parse_bbb_plone(dummy_guillotina): from guillotina.catalog.parser import BaseParser content = test_utils.create_content(Container) parser = BaseParser(None, content) result = parser( {"portal_type": "Folder", "SearchableText": "foobar", "b_size": 45, "b_start": 50, "path.depth": 2} ) assert "searchabletext__or" in result["params"] assert "title__in" in result["params"]["searchabletext__or"] assert "depth" in result["params"] assert "type_name" in result["params"] assert "portal_type" not in result["params"] assert result["_from"] == 50 assert result["size"] == 45
async def test_parse_bbb_plone(dummy_guillotina): from guillotina.catalog.parser import BaseParser content = test_utils.create_content(Container) parser = BaseParser(None, content) result = parser({ 'portal_type': 'Folder', 'SearchableText': 'foobar', 'b_size': 45, 'b_start': 50, 'path.depth': 2 }) assert 'searchabletext__or' in result['params'] assert 'title__in' in result['params']['searchabletext__or'] assert 'depth' in result['params'] assert 'type_name' in result['params'] assert 'portal_type' not in result['params'] assert result['_from'] == 50 assert result['size'] == 45