Skip to content

Commit

Permalink
fix result type in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchdawson1982 committed Feb 26, 2024
1 parent e94bb03 commit 52ec70f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion home/forms/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def get_domain_choices() -> list[tuple[str, str]]:
"""Make API call to obtain domain choices"""
# TODO: pull in the domains from the catalogue client
# facets = client.search_facets()
# domain_list = facets.options("domain")
# domain_list = facets.options("domains")
return [
("", "All Domains"),
("urn:li:domain:HMCTS", "HMCTS"),
Expand Down
12 changes: 4 additions & 8 deletions home/service/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,10 @@ def __init__(self, form: SearchForm, page: str, items_per_page: int = 20):
self.context = self._get_context()

@staticmethod
def _build_filter_strings(
def _build_custom_property_filter(
filter_param: str, filter_value_list: list[str]
) -> list[str]:
return (
[f"{filter_param}{filter_value}" for filter_value in filter_value_list]
if filter_value_list
else []
)
return [f"{filter_param}{filter_value}" for filter_value in filter_value_list]

def _get_search_results(self, page: str, items_per_page: int):
if self.form.is_bound:
Expand All @@ -50,10 +46,10 @@ def _get_search_results(self, page: str, items_per_page: int):
sort = form_data.get("sort", "relevance")
domain = form_data.get("domain", "")
domains_and_subdomains = domains_with_their_subdomains(domain)
classifications = self._build_filter_strings(
classifications = self._build_custom_property_filter(
"sensitivityLevel=", form_data.get("classifications", [])
)
where_to_access = self._build_filter_strings(
where_to_access = self._build_custom_property_filter(
"whereToAccessDataset=", form_data.get("where_to_access", [])
)
filter_value = []
Expand Down
3 changes: 2 additions & 1 deletion home/templatetags/lookup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from home.templatetags.markdown import register


@register.filter
def lookup(list, lookup_dict):
return sorted([lookup_dict.get(item)for item in list])
return sorted([lookup_dict.get(item) for item in list])
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def generate_page(page_size=20, result_type: ResultType = None):
results.append(
SearchResult(
id=fake.unique.name(),
result_type=choice((ResultType.DATA_PRODUCT, ResultType.TABLE)),
result_type=(
choice((ResultType.DATA_PRODUCT, ResultType.TABLE))
if result_type is None
Expand Down

0 comments on commit 52ec70f

Please sign in to comment.