diff --git a/src/version_parser.py b/src/version_parser.py
index 6e3f4d5..d67d820 100644
--- a/src/version_parser.py
+++ b/src/version_parser.py
@@ -26,7 +26,7 @@ def get_active_versions(page_content: bs) -> list[str]:
return active_versions_list
-def get_stable_releases_links(page_content: bs, active_versions_list: list)->list[str]:
+def get_stable_releases_links(page_content: bs, active_versions_list: list) -> list[str]:
active_stable_releases_link = []
stable_releases_links = page_content.find_all('a')
for link in stable_releases_links:
@@ -37,5 +37,17 @@ def get_stable_releases_links(page_content: bs, active_versions_list: list)->lis
return active_stable_releases_link
-def get_newest_releases_links(active_stable_releases_link: list[str]) -> list[str]:
- pass
\ No newline at end of file
+def group_releases_by_major_version(active_stable_releases_link: list[str], active_versions: list[str]):
+ last_stable_releases = dict.fromkeys(active_versions)
+ for key in last_stable_releases:
+ last_stable_releases[key] = []
+
+ for link in active_stable_releases_link:
+ a = re.search(r'\d+.\d+', link)[0]
+ last_stable_releases[a].append(link)
+
+ return last_stable_releases
+
+
+# group_releases_by_major_version(get_stable_releases_links(get_page_content(BASE_URL, 'downloads/source/'),
+# get_active_versions(get_page_content(BASE_URL, 'downloads/'))), get_active_versions(get_page_content(BASE_URL, 'downloads/')))
diff --git a/tests/test_download_link.html b/tests/test_download_link.html
index e244815..7348335 100644
--- a/tests/test_download_link.html
+++ b/tests/test_download_link.html
@@ -1,3 +1,3 @@
Gzipped source tarball
-Gzipped source tarball
-Gzipped source tarball
\ No newline at end of file
+Gzipped source tarball
+Gzipped source tarball
\ No newline at end of file
diff --git a/tests/test_parser.py b/tests/test_parser.py
index e70d387..d568912 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -5,8 +5,8 @@
from src.version_parser import *
BASE_URL = 'https://www.python.org/'
-correct_test_download_links = ['https://www.python.org/ftp/python/3.11.5/Python-3.11.4.tgz',\
- 'https://www.python.org/ftp/python/3.11.5/Python-3.11.9.tgz']
+correct_test_download_links = ['https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz',
+ 'https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz']
test_active_version_page = bs(Path('tests/test_active_versions.html')
.read_text(), 'lxml')
@@ -29,6 +29,10 @@ def test_get_stable_releases_link():
test_download_links_page, ['3.11'])
assert active_versions_links == correct_test_download_links
-def test_get_newest_releases_links():
- latest_releases_links = get_newest_releases_links(correct_test_download_links)
- assert latest_releases_links == ['https://www.python.org/ftp/python/3.11.5/Python-3.11.9.tgz']
\ No newline at end of file
+
+def test_grouping_releases_by_major_version():
+ latest_releases_links = group_releases_by_major_version(
+ correct_test_download_links, ['3.11'])
+ print(latest_releases_links)
+ assert latest_releases_links == {
+ '3.11': correct_test_download_links}