Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/cgit/tests/test_lister.py
| Show All 15 Lines | |||||
| def test_lister_cgit_get_pages_one_page(requests_mock_datadir, swh_scheduler): | def test_lister_cgit_get_pages_one_page(requests_mock_datadir, swh_scheduler): | ||||
| url = "https://git.savannah.gnu.org/cgit/" | url = "https://git.savannah.gnu.org/cgit/" | ||||
| lister_cgit = CGitLister(swh_scheduler, url=url) | lister_cgit = CGitLister(swh_scheduler, url=url) | ||||
| repos: List[List[str]] = list(lister_cgit.get_pages()) | repos: List[List[str]] = list(lister_cgit.get_pages()) | ||||
| flattened_repos = sum(repos, []) | flattened_repos = sum(repos, []) | ||||
| assert len(flattened_repos) == 977 | assert len(flattened_repos) == 977 | ||||
| assert ( | assert flattened_repos[0]["url"] == "https://git.savannah.gnu.org/cgit/elisp-es.git" | ||||
| flattened_repos[0]["url"] == "https://git.savannah.gnu.org/cgit/elisp-es.git/" | |||||
| ) | |||||
| # note the url below is NOT a subpath of /cgit/ | # note the url below is NOT a subpath of /cgit/ | ||||
| assert ( | assert ( | ||||
| flattened_repos[-1]["url"] == "https://git.savannah.gnu.org/path/to/yetris.git/" | flattened_repos[-1]["url"] == "https://git.savannah.gnu.org/path/to/yetris.git" | ||||
| ) # noqa | ) # noqa | ||||
| # note the url below is NOT on the same server | # note the url below is NOT on the same server | ||||
| assert flattened_repos[-2]["url"] == "http://example.org/cgit/xstarcastle.git/" | assert flattened_repos[-2]["url"] == "http://example.org/cgit/xstarcastle.git" | ||||
| def test_lister_cgit_get_pages_with_pages(requests_mock_datadir, swh_scheduler): | def test_lister_cgit_get_pages_with_pages(requests_mock_datadir, swh_scheduler): | ||||
| url = "https://git.tizen/cgit/" | url = "https://git.tizen/cgit/" | ||||
| lister_cgit = CGitLister(swh_scheduler, url=url) | lister_cgit = CGitLister(swh_scheduler, url=url) | ||||
| repos: List[List[str]] = list(lister_cgit.get_pages()) | repos: List[List[str]] = list(lister_cgit.get_pages()) | ||||
| flattened_repos = sum(repos, []) | flattened_repos = sum(repos, []) | ||||
| ▲ Show 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | def test_lister_cgit_date_parsing(date_str, expected_date): | ||||
| """test cgit lister date parsing""" | """test cgit lister date parsing""" | ||||
| repository = {"url": "url", "last_updated_date": date_str} | repository = {"url": "url", "last_updated_date": date_str} | ||||
| assert _parse_last_updated_date(repository) == expected_date | assert _parse_last_updated_date(repository) == expected_date | ||||
| requests_mock_datadir_missing_url = requests_mock_datadir_factory( | requests_mock_datadir_missing_url = requests_mock_datadir_factory( | ||||
| ignore_urls=["https://git.tizen/cgit/adaptation/ap_samsung/audio-hal-e4x12/",] | ignore_urls=["https://git.tizen/cgit/adaptation/ap_samsung/audio-hal-e4x12",] | ||||
| ) | ) | ||||
| def test_lister_cgit_get_origin_from_repo_failing( | def test_lister_cgit_get_origin_from_repo_failing( | ||||
| requests_mock_datadir_missing_url, swh_scheduler | requests_mock_datadir_missing_url, swh_scheduler | ||||
| ): | ): | ||||
| url = "https://git.tizen/cgit/" | url = "https://git.tizen/cgit/" | ||||
| lister_cgit = CGitLister(swh_scheduler, url=url) | lister_cgit = CGitLister(swh_scheduler, url=url) | ||||
| ▲ Show 20 Lines • Show All 76 Lines • Show Last 20 Lines | |||||