Skip to content

Release/2.11.1 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.11.1] - 2025-04-28

### Fixed

- Eflyt case search now handles list of cases without a deadline

## [2.11.0] - 2025-03-24

### Changed
Expand Down Expand Up @@ -214,7 +220,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release

[Unreleased]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.11.0...HEAD
[Unreleased]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.11.1...HEAD
[2.11.1]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.11.1
[2.11.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.11.0
[2.10.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.10.0
[2.9.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.9.0
Expand Down
32 changes: 16 additions & 16 deletions itk_dev_shared_components/eflyt/eflyt_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,33 @@ def extract_cases(browser: webdriver.Chrome) -> list[Case]:
"""
table = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_GridViewSearchResult")
rows = table.find_elements(By.TAG_NAME, "tr")
headlines = rows[0].text.split(" ")

# Remove header row
rows.pop(0)
cases = []
for row in rows:
deadline = row.find_element(By.XPATH, "td[3]/a").text

# Convert deadline to date object
if deadline:
deadline = datetime.strptime(deadline, "%d-%m-%Y")
else:
deadline = None
deadline = None
if "Deadline" in headlines:
deadline_text = row.find_element(By.XPATH, f"td[{headlines.index('Deadline') + 1}]/a").text
# Convert deadline to date object
if len(deadline_text) > 0:
deadline = datetime.strptime(deadline_text, "%d-%m-%Y")

case_number = row.find_element(By.XPATH, "td[4]").text
case_types_text = row.find_element(By.XPATH, "td[5]").text
case_number = row.find_element(By.XPATH, f"td[{headlines.index('Sagsnr.') + 1}]").text
case_types_text = row.find_element(By.XPATH, f"td[{headlines.index('Flyttetype') + 1}]").text

# If the case types ends with '...' we need to get the title instead
if case_types_text.endswith("..."):
case_types_text = row.find_element(By.XPATH, "td[5]").get_attribute("Title")
case_types_text = row.find_element(By.XPATH, f"td[{headlines.index('Flyttetype') + 1}]").get_attribute("Title")
case_types = case_types_text.split(", ")

status = row.find_element(By.XPATH, "td[6]").text
cpr = row.find_element(By.XPATH, "td[7]/a").text
name = row.find_element(By.XPATH, "td[8]").text
case_worker = row.find_element(By.XPATH, "td[10]").text
status = row.find_element(By.XPATH, f"td[{headlines.index('Status') + 1}]").text
cpr = row.find_element(By.XPATH, f"td[{headlines.index('CPR-nr.') + 1}]/a").text
name = row.find_element(By.XPATH, f"td[{headlines.index('Navn') + 1}]").text
case_worker = row.find_element(By.XPATH, f"td[{headlines.index('Sagsbehandler') + 2}]").text # eFlyt has an additional empty column before "Sagsbehandler"

case = Case(case_number, deadline, case_types, status, cpr, name, case_worker)
cases.append(case)
cases.append(Case(case_number, deadline, case_types, status, cpr, name, case_worker))

return cases

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "itk_dev_shared_components"
version = "2.11.0"
version = "2.11.1"
authors = [
{ name="ITK Development", email="[email protected]" },
]
Expand Down
43 changes: 30 additions & 13 deletions tests/test_eflyt/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,39 @@ def setUpClass(cls):

def test_extract_cases(self):
"""Extract cases and check we found what we expected"""
eflyt_search.search(self.browser, date.today() - timedelta(days=2), date.today())
eflyt_search.search(self.browser, date.today() - timedelta(days=2), date.today(), case_state="Afsluttet", case_status="Godkendt")
cases = eflyt_search.extract_cases(self.browser)

self.assertGreater(len(cases), 0)
case = cases[0]

self.assertIsInstance(case.case_number, str)
self.assertIsInstance(case.case_types, list)
self.assertIsInstance(case.deadline, (date, type(None)))
self.assertIsInstance(case.status, str)
self.assertIsInstance(case.cpr, str)
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
self.assertIsInstance(case.name, str)
self.assertGreater(len(case.name), 0)
self.assertIsInstance(case.case_worker, str)
self.assertGreater(len(case.case_worker), 0)
for case in cases:
self.assertIsInstance(case.case_number, str)
self.assertIsInstance(case.case_types, list)
self.assertIsInstance(case.deadline, (date, type(None)))
self.assertIsInstance(case.status, str)
self.assertIsInstance(case.cpr, str)
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
self.assertIsInstance(case.name, str)
self.assertGreater(len(case.name), 0)
self.assertIsInstance(case.case_worker, str)
self.assertGreater(len(case.case_worker), 0)

def test_extract_cases_deadline(self):
"""Extract cases and check we found what we expected"""
eflyt_search.search(self.browser, date.today() - timedelta(days=2), date.today(), case_status="Godkendt")
cases = eflyt_search.extract_cases(self.browser)

self.assertGreater(len(cases), 0)
for case in cases:
self.assertIsInstance(case.case_number, str)
self.assertIsInstance(case.case_types, list)
self.assertIsInstance(case.deadline, (date, type(None)))
self.assertIsInstance(case.status, str)
self.assertIsInstance(case.cpr, str)
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
self.assertIsInstance(case.name, str)
self.assertGreater(len(case.name), 0)
self.assertIsInstance(case.case_worker, str)
self.assertGreater(len(case.case_worker), 0)

def test_open_case(self):
"""Open a case and check the browser opened the case view"""
Expand Down