Skip to content

Commit

Permalink
create tests for pubtype
Browse files Browse the repository at this point in the history
  • Loading branch information
edulauer committed Nov 11, 2024
1 parent 2849628 commit 97a444f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 9 deletions.
7 changes: 5 additions & 2 deletions tests/inlabs_searcher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@


@pytest.mark.parametrize(
"search_terms, sections, department, reference_date, search_date, filters_applyed",
"search_terms, sections, department, pubtype, reference_date, search_date, filters_applyed",
[
(
{"texto": ["a", "b"]},
["SECAO_2"],
["Ministério"],
["Edital"],
datetime.now(),
"DIA",
{
"texto": ["a", "b"],
"pubname": ["DO2"],
"artcategory": ["Ministério"],
"arttype": ["Edital"],
"pubdate": [
datetime.now().strftime("%Y-%m-%d"),
datetime.now().strftime("%Y-%m-%d"),
Expand All @@ -32,13 +34,14 @@ def test_apply_filters(
search_terms,
sections,
department,
pubtype,
reference_date,
search_date,
filters_applyed,
):
assert (
inlabs_searcher._apply_filters(
search_terms, sections, department, reference_date, search_date
search_terms, sections, department, pubtype, reference_date, search_date
)
== filters_applyed
)
Expand Down
81 changes: 74 additions & 7 deletions tests/parsers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
{
"id": "basic_example",
"description": "DAG de teste",
"schedule": None,
"dataset": None,
"skip_null": True,
"doc_md": None,
"tags": {"dou", "generated_dag"},
"owner": [],
"search": [
{
"terms": [
Expand All @@ -43,6 +49,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand All @@ -51,13 +58,6 @@
"attach_csv": False,
"discord_webhook": None,
"slack_webhook": None,
"schedule": None,
"dataset": None,
"description": "DAG de teste",
"skip_null": True,
"doc_md": None,
"tags": {"dou", "generated_dag"},
"owner": [],
"hide_filters": False,
"header_text": None,
"footer_text": None,
Expand Down Expand Up @@ -97,6 +97,7 @@
"full_text": True,
"use_summary": True,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -152,6 +153,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -195,6 +197,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -250,6 +253,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -296,6 +300,7 @@
"Ministério da Gestão e da Inovação em Serviços Públicos",
"Ministério da Defesa",
],
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -339,6 +344,7 @@
"full_text": False,
"use_summary": True,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -386,6 +392,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -432,6 +439,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
},
{
"terms": [
Expand Down Expand Up @@ -474,6 +482,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
},
],
"report": {
Expand Down Expand Up @@ -520,6 +529,7 @@
"Ministério da Gestão e da Inovação em Serviços Públicos",
"Ministério da Defesa",
],
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -563,6 +573,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand Down Expand Up @@ -609,6 +620,7 @@
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": None,
}
],
"report": {
Expand All @@ -626,6 +638,61 @@
},
},
),
(
"pubtype_example.yaml",
{
"id": "pubtype_example",
"description": "DAG de teste (filtro por tipo de publicação)",
"schedule": None,
"dataset": None,
"doc_md": None,
"tags": {"dou", "generated_dag"},
"owner": [],
"search": [
{
"terms": [
"programa",
],
"header": None,
"sources": ["DOU"],
"sql": None,
"conn_id": None,
"dou_sections": ["TODOS"],
"search_date": "DIA",
"field": "TUDO",
"is_exact_search": True,
"ignore_signature_match": False,
"force_rematch": False,
"full_text": False,
"use_summary": False,
"department": None,
"pubtype": [
"Ato",
"Portaria",
"Edital",
"Extrato",
"Ratificação",
"Resolução",
"Retificação",
"Protocolo"
],
}
],
"report": {
"emails": ["[email protected]"],
"subject": "Teste do Ro-dou",
"attach_csv": False,
"discord_webhook": None,
"slack_webhook": None,
"skip_null": True,
"hide_filters": False,
"header_text": None,
"footer_text": None,
"no_results_found_text": "Nenhum dos termos pesquisados "
"foi encontrado nesta consulta",
},
},
),
],
)
def test_parse(filepath, result_tuple):
Expand Down
28 changes: 28 additions & 0 deletions tests/searchers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,34 @@ def test_match_department(dou_searcher):
dou_searcher._match_department(results, department)
assert len(results) == 1

def test_match_pubtype(dou_searcher):
pubtype = ["Edital"]
results = [
{
"section": "Seção 3",
"title": "EXTRATO DE COMPROMISSO",
"href": "https://www.in.gov.br/web/dou/-/extrato-de-compromisso-342504508",
"abstract": "ALESSANDRO GLAUCO DOS ANJOS DE VASCONCELOS - Secretário-Executivo Adjunto...",
"date": "02/09/2021",
"arttype": [
"Edital",
"Ata",
"Portaria",
],
},
{
"section": "Seção 3",
"title": "EXTRATO DE COMPROMISSO",
"href": "https://www.in.gov.br/web/dou/-/extrato-de-compromisso-342504508",
"abstract": "ALESSANDRO GLAUCO DOS ANJOS DE VASCONCELOS - Secretário-Executivo Adjunto...",
"date": "02/09/2021",
"arttype": ["Portaria"],
},
]
dou_searcher._match_pubtype(results, pubtype)
assert len(results) == 1



@pytest.mark.parametrize(
"pre_term_list, casted_term_list",
Expand Down

0 comments on commit 97a444f

Please sign in to comment.