-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_endpoint_first_tab.py
More file actions
85 lines (74 loc) · 2.12 KB
/
Copy pathtest_endpoint_first_tab.py
File metadata and controls
85 lines (74 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import pytest
solr_config = {
"fieldList": [
"UID",
"Title",
"Description",
"Type",
"effective",
"start",
"created",
"end",
"path_string",
"phone",
"email",
"location",
],
"searchTabs": [
{
"label": "All except Pages",
"filter": "-Type:(Page)",
},
{
"label": "Pages",
"filter": "Type:(Page)",
},
{
"label": "News Items",
"filter": 'Type:("News Item")',
},
{
"label": "Pages and News Items",
"filter": 'Type:(Page OR "News Item")',
},
],
}
@pytest.fixture(scope="class")
def registry_config() -> dict:
"""Override registry configuration."""
return {
"collective.solr.active": 1,
"kitconcept.solr.config": solr_config,
}
class TestEndpointFirstTab:
@pytest.fixture(autouse=True, scope="class")
def _init(self, request, portal_with_content, manager_request):
request.cls.portal = portal_with_content
response = manager_request.get(request.cls.url)
request.cls.data = response.json()
class TestEndpointFirstTabBaseSearch(TestEndpointFirstTab):
url = "/@solr?q=chomsky"
def test_facet_groups(self):
# Using default configuration
assert "response" in self.data
assert self.data.get("facet_groups") == [
["All except Pages", 2],
["Pages", 1],
["News Items", 1],
["Pages and News Items", 2],
]
@pytest.mark.parametrize(
"path,expected",
[
("/plone/mydocument", False),
("/plone/noamchomsky", True),
("/plone/mynews", True),
],
)
def test_paths(self, all_path_string, path: str, expected: bool):
path_strings = all_path_string(self.data)
assert (path in path_strings) is expected
def test_portal_path(self):
"""portal_path is returned for the client"""
assert "response" in self.data
assert self.data.get("portal_path") == "/plone"