Skip to content

Commit d73b6fb

Browse files
authored
Merge pull request #105 from itk-dev-rpa/release/2.11.1
Release/2.11.1
2 parents b8bf3f0 + ff3391a commit d73b6fb

File tree

4 files changed

+55
-31
lines changed

4 files changed

+55
-31
lines changed

changelog.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [2.11.1] - 2025-04-28
11+
12+
### Fixed
13+
14+
- Eflyt case search now handles list of cases without a deadline
15+
1016
## [2.11.0] - 2025-03-24
1117

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

215221
- Initial release
216222

217-
[Unreleased]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.11.0...HEAD
223+
[Unreleased]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/compare/2.11.1...HEAD
224+
[2.11.1]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.11.1
218225
[2.11.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.11.0
219226
[2.10.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.10.0
220227
[2.9.0]: https://github.com/itk-dev-rpa/ITK-dev-shared-components/releases/tag/2.9.0

itk_dev_shared_components/eflyt/eflyt_search.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ def extract_cases(browser: webdriver.Chrome) -> list[Case]:
5858
"""
5959
table = browser.find_element(By.ID, "ctl00_ContentPlaceHolder2_GridViewSearchResult")
6060
rows = table.find_elements(By.TAG_NAME, "tr")
61+
headlines = rows[0].text.split(" ")
62+
6163
# Remove header row
6264
rows.pop(0)
6365
cases = []
6466
for row in rows:
65-
deadline = row.find_element(By.XPATH, "td[3]/a").text
66-
67-
# Convert deadline to date object
68-
if deadline:
69-
deadline = datetime.strptime(deadline, "%d-%m-%Y")
70-
else:
71-
deadline = None
67+
deadline = None
68+
if "Deadline" in headlines:
69+
deadline_text = row.find_element(By.XPATH, f"td[{headlines.index('Deadline') + 1}]/a").text
70+
# Convert deadline to date object
71+
if len(deadline_text) > 0:
72+
deadline = datetime.strptime(deadline_text, "%d-%m-%Y")
7273

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

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

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

86-
case = Case(case_number, deadline, case_types, status, cpr, name, case_worker)
87-
cases.append(case)
87+
cases.append(Case(case_number, deadline, case_types, status, cpr, name, case_worker))
8888

8989
return cases
9090

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "itk_dev_shared_components"
7-
version = "2.11.0"
7+
version = "2.11.1"
88
authors = [
99
{ name="ITK Development", email="[email protected]" },
1010
]

tests/test_eflyt/test_search.py

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,39 @@ def setUpClass(cls):
2424

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

3030
self.assertGreater(len(cases), 0)
31-
case = cases[0]
32-
33-
self.assertIsInstance(case.case_number, str)
34-
self.assertIsInstance(case.case_types, list)
35-
self.assertIsInstance(case.deadline, (date, type(None)))
36-
self.assertIsInstance(case.status, str)
37-
self.assertIsInstance(case.cpr, str)
38-
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
39-
self.assertIsInstance(case.name, str)
40-
self.assertGreater(len(case.name), 0)
41-
self.assertIsInstance(case.case_worker, str)
42-
self.assertGreater(len(case.case_worker), 0)
31+
for case in cases:
32+
self.assertIsInstance(case.case_number, str)
33+
self.assertIsInstance(case.case_types, list)
34+
self.assertIsInstance(case.deadline, (date, type(None)))
35+
self.assertIsInstance(case.status, str)
36+
self.assertIsInstance(case.cpr, str)
37+
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
38+
self.assertIsInstance(case.name, str)
39+
self.assertGreater(len(case.name), 0)
40+
self.assertIsInstance(case.case_worker, str)
41+
self.assertGreater(len(case.case_worker), 0)
42+
43+
def test_extract_cases_deadline(self):
44+
"""Extract cases and check we found what we expected"""
45+
eflyt_search.search(self.browser, date.today() - timedelta(days=2), date.today(), case_status="Godkendt")
46+
cases = eflyt_search.extract_cases(self.browser)
47+
48+
self.assertGreater(len(cases), 0)
49+
for case in cases:
50+
self.assertIsInstance(case.case_number, str)
51+
self.assertIsInstance(case.case_types, list)
52+
self.assertIsInstance(case.deadline, (date, type(None)))
53+
self.assertIsInstance(case.status, str)
54+
self.assertIsInstance(case.cpr, str)
55+
self.assertRegex(case.cpr, r"\d{6}-\d{4}")
56+
self.assertIsInstance(case.name, str)
57+
self.assertGreater(len(case.name), 0)
58+
self.assertIsInstance(case.case_worker, str)
59+
self.assertGreater(len(case.case_worker), 0)
4360

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

0 commit comments

Comments
 (0)