@@ -669,3 +669,28 @@ def test_group_facet_api_call(self):
669669
670670 self .assertDictEqual (expected_response_filtered , response_dict_filtered )
671671 self .assertDictEqual (expected_response_base , response_dict_base )
672+
673+ def test_group_facets_are_filtered_by_words (self ):
674+ # there are some groups and the facets return them
675+ url = f"{ reverse ('get_facet' ,args = ['group' ])} "
676+
677+ response = self .client .get (url )
678+ self .assertEqual (200 , response .status_code , response .json ())
679+
680+ self .assertTrue (response .json ().get ("topics" , {}).get ("total" , 0 ) > 0 )
681+
682+ # topic_contains with real name should return 1
683+ url = f"{ reverse ('get_facet' ,args = ['group' ])} ?topic_contains=UserAdmin"
684+ response = self .client .get (url )
685+
686+ self .assertEqual (200 , response .status_code , response .json ())
687+
688+ self .assertEqual (1 , response .json ().get ("topics" , {}).get ("total" , 0 ))
689+
690+ # topic_contains with a random string to be searched for should be 0
691+ url = f"{ reverse ('get_facet' ,args = ['group' ])} ?topic_contains=abc123scfuqbrwefbasascgiu"
692+ response = self .client .get (url )
693+
694+ self .assertEqual (200 , response .status_code , response .json ())
695+
696+ self .assertEqual (0 , response .json ().get ("topics" , {}).get ("total" , 0 ))
0 commit comments