def test_search_name_and_additional_col_as_str(self, query): utils.search_df(df, "nome", {"pesquisa_nome": "pesquisa"}) expected = "nome.str.contains('(?iu)nome') and pesquisa_nome.str.contains('(?iu)pesquisa')" query.assert_called_with(expected, engine="python")
def test_search_full_list(self, query): utils.search_df(df, [1, 2, 3]) expected = "nome.str.contains('(?iu)1|2|3')" query.assert_called_with(expected, engine="python")
def test_search_str(self, query): utils.search_df(df, "oi") expected = "nome.str.contains('(?iu)oi')" query.assert_called_with(expected, engine="python")
def test_if_raises_do_search_invalid_filter(self): with self.assertRaises(ValueError): utils.search_df(df, "nome", {"non_existent_column": "string"})
def test_search_with_two_additional_cols(self, query): utils.search_df( df, ["oi", "tudo"], {"pesquisa_nome": ["DD", "DI"], "pesquisa_id": "AA"} ) expected = "nome.str.contains('(?iu)oi|tudo') and pesquisa_nome.str.contains('(?iu)DD|DI') and pesquisa_id.str.contains('(?iu)AA')" query.assert_called_with(expected, engine="python")
def test_search_name_and_additional_col_as_lists(self, query): utils.search_df(df, ["nome", "outro"], {"pesquisa_nome": ["pesquisa", "outra"]}) expected = "nome.str.contains('(?iu)nome|outro') and pesquisa_nome.str.contains('(?iu)pesquisa|outra')" query.assert_called_with(expected, engine="python")