From 13c122ae81bae0e3b751bc7a04aeb029ab7774ed Mon Sep 17 00:00:00 2001
From: salomaolopes <salopesousa@hotmail.com>
Date: Thu, 24 Oct 2024 11:37:27 -0300
Subject: [PATCH] Create test to implementation qd_list_territory_id

---
 tests/parsers_test.py     | 47 +++++++++++++++++++++++++++++++++++++++
 tests/qd_searcher_test.py | 20 +++++++++++++++++
 2 files changed, 67 insertions(+)

diff --git a/tests/parsers_test.py b/tests/parsers_test.py
index cc49115..91d3375 100644
--- a/tests/parsers_test.py
+++ b/tests/parsers_test.py
@@ -579,6 +579,53 @@
                 },
             },
         ),
+        (
+            "qd_list_territory_id_example.yaml",
+            {
+                "id": "qd_list_territory_id_example",
+                "description": "DAG de teste com múltiplos territory_id",
+                "schedule": '0 8 * * MON-FRI',
+                "dataset": None,
+                "doc_md": None,
+                "tags": {"dou", "generated_dag"},
+                "owner": [],
+                "search": [
+                    {
+                        "terms": [
+                            "LGPD",
+                            "RIO DE JANEIRO",
+                        ],
+                        "header": "Teste com múltiplos territory_id",
+                        "sources": ["QD"],
+                        "sql": None,
+                        "conn_id": None,
+                        "territory_id": [3300100,3300159,3300209,3305703],
+                        "dou_sections": ["TODOS"],
+                        "search_date": "DIA",
+                        "field": "TUDO",
+                        "is_exact_search": True,
+                        "ignore_signature_match": True,
+                        "force_rematch": True,
+                        "full_text": False,
+                        "use_summary": False,
+                        "department": None,
+                    }
+                ],
+                "report": {
+                    "emails": ["destination@economia.gov.br"],
+                    "subject": "Teste do Ro-dou",
+                    "attach_csv": False,
+                    "discord_webhook": None,
+                    "slack_webhook": None,
+                    "skip_null": False,
+                    "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):
diff --git a/tests/qd_searcher_test.py b/tests/qd_searcher_test.py
index 309582e..1535aa3 100644
--- a/tests/qd_searcher_test.py
+++ b/tests/qd_searcher_test.py
@@ -79,3 +79,23 @@ def test_build_query_payload(pre_tags: str,
     ]
 
     assert payload == expected
+
+
+@pytest.mark.parametrize(
+    'territory_id, expected_payload',
+    [
+        (3300100, [('territory_ids', 3300100)]),
+        ([3300100, 3300159], [('territory_ids', 3300100), ('territory_ids', 3300159)]),
+    ]
+)
+def test_search_with_multiple_territory_ids(territory_id, expected_payload):
+    #searcher = QDSearcher()
+    payload = []
+
+    # Simula a lógica que foi alterada para suportar múltiplos IDs de território
+    if isinstance(territory_id, int):
+        territory_id = [territory_id]
+    for terr_id in territory_id:
+        payload.append(('territory_ids', terr_id))
+
+    assert payload == expected_payload
\ No newline at end of file