Skip to content

Commit

Permalink
Add more tests for Web UI search
Browse files Browse the repository at this point in the history
Add tests for empty string query and query string that only
contains whitespace chars
  • Loading branch information
candleindark committed Mar 25, 2024
1 parent 68dc0e0 commit c70b3b9
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions datalad_registry/tests/test_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,19 @@ def test_search_with_valid_query(

@pytest.mark.usefixtures("populate_with_dataset_urls")
@pytest.mark.parametrize(
"search_query",
"search_query, err_msg_prefix",
[
"unknown_field:example",
("unknown_field:example", "Unknown field: 'unknown_field'. Known are:"),
("", "Query string cannot be empty"),
(" \t \n", "Query string cannot contain only whitespace"),
(" ", "Query string cannot contain only whitespace"),
(" ", "Query string cannot contain only whitespace"),
(" \t \n \t ", "Query string cannot contain only whitespace"),
],
)
def test_search_with_invalid_query(self, search_query: Optional[str], flask_client):
def test_search_with_invalid_query(
self, search_query: str, err_msg_prefix: str, flask_client
):
"""
Test searching with an invalid query
"""
Expand All @@ -197,9 +204,7 @@ def test_search_with_invalid_query(self, search_query: Optional[str], flask_clie
soup = BeautifulSoup(resp.text, "html.parser")

assert (error_span := soup.find("span", class_="error"))
assert error_span.text.startswith(
"ERROR: Unknown field: 'unknown_field'. Known are:"
)
assert error_span.text.startswith(f"ERROR: {err_msg_prefix}")

def test_pagination(self, populate_with_dataset_urls, flask_client):
"""
Expand Down

0 comments on commit c70b3b9

Please sign in to comment.