Skip to content

Commit 6993603

Browse files
authored
Merge pull request #115 from unicef/feature/test-export-generation
Add tests for export generation of households and individuals
2 parents 0ff431c + d0501cf commit 6993603

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/functional/test_f_household.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from typing import TYPE_CHECKING
2+
from unittest.mock import patch
23

34
import pytest
45
from django.core.management import call_command
56
from testutils.factories import OfficeFactory
67
from testutils.factories.program import BeneficiaryGroupFactory
78
from testutils.factories import CountryProgramFactory
89

10+
from tests.extras.testutils.selenium import CountryWorkspaceSeleniumTC
11+
912
if TYPE_CHECKING:
1013
from country_workspace.workspaces.models import CountryHousehold
1114

@@ -79,3 +82,40 @@ def test_list_household_select_all_fields(browser, household: "CountryHousehold"
7982
checkboxes = browser.find_elements('input[type="checkbox"][name="fields"]')
8083
for cb in checkboxes:
8184
assert cb.is_selected()
85+
86+
87+
def _test_export_generation(browser: CountryWorkspaceSeleniumTC, household: "CountryHousehold", link: str):
88+
browser.login_as_user()
89+
browser.select_option_by_text("select[name=tenant]", household.program.country_office.name)
90+
browser.select2_select("id_program", household.program.name)
91+
browser.click_link(link)
92+
93+
browser.click("#action-toggle")
94+
browser.select_option_by_text("select[name=action]", "Export records as .xlsx for bulk updates")
95+
96+
browser.click("button[name='index'][value='0']")
97+
browser.click("#select-all")
98+
browser.click("input[name='_export']")
99+
100+
browser.click('//a[div[text()="Async Jobs"]]')
101+
browser.wait_for_element("table#result_list", timeout=10)
102+
rows = browser.find_elements("table#result_list tbody tr")
103+
assert any("Export records as .xlsx for bulk updates" in row.text for row in rows)
104+
105+
106+
@pytest.mark.selenium
107+
@patch("country_workspace.workspaces.admin.cleaners.bulk_update.bulk_update_export_template")
108+
def test_households_export_generation(
109+
mocked_exporter, browser: CountryWorkspaceSeleniumTC, household: "CountryHousehold"
110+
):
111+
mocked_exporter.return_value = None
112+
_test_export_generation(browser=browser, household=household, link="Households")
113+
114+
115+
@pytest.mark.selenium
116+
@patch("country_workspace.workspaces.admin.cleaners.bulk_update.bulk_update_export_template")
117+
def test_individuals_export_generation(
118+
mocked_exporter, browser: CountryWorkspaceSeleniumTC, household: "CountryHousehold"
119+
):
120+
mocked_exporter.return_value = None
121+
_test_export_generation(browser=browser, household=household, link="Individuals")

0 commit comments

Comments
 (0)