This PR fixes incorrect logic with get_current_ver and the relevant unit tests.
A broken unit test:
requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn't match any registered mock.
Request:
- GET https://results.enr.clarityelections.com/KY/50972/131636/en/summary.html/current_ver.txt
revealed that this function doesn't correctly truncate the URL path before appending /current_ver.txt. The correct URL should be https://results.enr.clarityelections.com/KY/50972/current_ver.txt (the version file is always in the election_id directory).
The logic fix involved using a RegEx to detect the first 2 or 3 directories of the URL path (depending on jurisdiction level of the election page).
Also, I broke the relevant 1 test function with 4 loop iterations into 1 test function per intent which helps name+describe the intent for each test and helps developers quickly identify which test/intent failed.
This PR fixes incorrect logic with
get_current_ver
and the relevant unit tests.A broken unit test:
revealed that this function doesn't correctly truncate the URL path before appending
/current_ver.txt
. The correct URL should behttps://results.enr.clarityelections.com/KY/50972/current_ver.txt
(the version file is always in theelection_id
directory).The logic fix involved using a RegEx to detect the first 2 or 3 directories of the URL path (depending on jurisdiction level of the election page).
Also, I broke the relevant 1 test function with 4 loop iterations into 1 test function per intent which helps name+describe the intent for each test and helps developers quickly identify which test/intent failed.