Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorbellini committed Mar 27, 2024
1 parent 55653f6 commit 1ffca1a
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions tests/inlabs_searcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,46 @@
"""

from datetime import datetime
from collections import Counter
import pytest


@pytest.mark.parametrize(
"search_terms, sections, department, reference_date, search_date, filters_applyed",
[
({"texto": ["a", "b"]}, ["SECAO_2"], ["Ministério"], datetime.now(), "DIA",
(
{"texto": ["a", "b"]},
["SECAO_2"],
["Ministério"],
datetime.now(),
"DIA",
{
"texto": ["a", "b"],
"pub_name": ["DO2"],
"art_category": ["Ministério"],
"pub_date": [datetime.now().strftime("%Y-%m-%d"), datetime.now().strftime("%Y-%m-%d")],
}
"pub_date": [
datetime.now().strftime("%Y-%m-%d"),
datetime.now().strftime("%Y-%m-%d"),
],
},
),
],
)
def test_apply_filters(
inlabs_searcher, search_terms, sections, department, reference_date, search_date, filters_applyed
inlabs_searcher,
search_terms,
sections,
department,
reference_date,
search_date,
filters_applyed,
):
assert inlabs_searcher._apply_filters(
assert (
inlabs_searcher._apply_filters(
search_terms, sections, department, reference_date, search_date
) == filters_applyed
)
== filters_applyed
)


@pytest.mark.parametrize(
Expand All @@ -37,7 +55,15 @@ def test_apply_filters(
],
)
def test_prepare_search_terms(inlabs_searcher, terms, search_terms):
assert inlabs_searcher._prepare_search_terms(terms) == search_terms
search_terms_return = inlabs_searcher._prepare_search_terms(terms)
assert set(search_terms_return.keys()) == set(
search_terms.keys()
), "The dictionaries do not have the same keys."

for key in search_terms_return:
assert Counter(search_terms_return[key]) == Counter(
search_terms[key]
), f"The lists under the key '{key}' do not have the same content."


@pytest.mark.parametrize(
Expand Down

0 comments on commit 1ffca1a

Please sign in to comment.