Skip to content

Commit

Permalink
Add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
cgodwin1 committed Aug 26, 2024
1 parent 51dc760 commit 3d394e4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion solution/backend/content_search/tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,18 +237,27 @@ def test_rank_sorting(self):
# This test ensures that reg text is included in the search results, and only if show_regulations is set to true or not set.
def test_reg_text_search(self):
self.login()

# Exclude resources but this search will not match any reg text
response = self.client.get("/v3/content-search/?q=fire&show_internal=false&show_public=false")
data = get_paginated_data(response)
self.assertEqual(data['count'], 0)

# Reg text should not show up for this search
response = self.client.get("/v3/content-search/?q=fire")
data = get_paginated_data(response)
self.assertEqual(data['count'], 2)

# Ensure that excluding reg text works
response = self.client.get("/v3/content-search/?q=federal&show_regulations=false")
data = get_paginated_data(response)
self.assertEqual(data['count'], 1)

# Ensure that reg text is included in the search results and the structure is correct
response = self.client.get("/v3/content-search/?q=federal")
data = get_paginated_data(response)
self.assertEqual(data['count'], 3)
self.assertTrue(any([i["reg_text"] is not None for i in data["results"]]))
self.assertTrue(any([i["reg_text"] for i in data["results"]]))
for i in [i for i in data["results"] if i["reg_text"] is not None]:
self.assertEqual(i["reg_text"]["title"], 42)
self.assertEqual(i["reg_text"]["date"], "2023-01-01")
Expand Down

0 comments on commit 3d394e4

Please sign in to comment.