fix(ci): fix ruff lint
This commit is contained in:
parent
db391da52c
commit
3b768cc6c4
3 changed files with 19 additions and 9 deletions
|
|
@ -42,6 +42,16 @@ _REGISTRY_FUNCTIONS = [
|
||||||
|
|
||||||
__all__ = _BASE_EXPORTS + _SCRAPER_CLASSES + _REGISTRY_FUNCTIONS
|
__all__ = _BASE_EXPORTS + _SCRAPER_CLASSES + _REGISTRY_FUNCTIONS
|
||||||
|
|
||||||
|
_exported_types = (
|
||||||
|
ScraperConfig,
|
||||||
|
ContestListResult,
|
||||||
|
ContestSummary,
|
||||||
|
MetadataResult,
|
||||||
|
ProblemSummary,
|
||||||
|
TestCase,
|
||||||
|
TestsResult,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_scraper(platform: str) -> type[BaseScraper]:
|
def get_scraper(platform: str) -> type[BaseScraper]:
|
||||||
if platform not in ALL_SCRAPERS:
|
if platform not in ALL_SCRAPERS:
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ def test_scrape_success(mocker, mock_codeforces_html):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_problem_tests("1900", "A")
|
result = scraper.scrape_problem_tests("1900", "A")
|
||||||
|
|
||||||
assert result.success == True
|
assert result.success
|
||||||
assert len(result.tests) == 1
|
assert len(result.tests) == 1
|
||||||
assert result.tests[0].input == "1\n3\n1 2 3"
|
assert result.tests[0].input == "1\n3\n1 2 3"
|
||||||
assert result.tests[0].expected == "6"
|
assert result.tests[0].expected == "6"
|
||||||
|
|
@ -39,7 +39,7 @@ def test_scrape_contest_problems(mocker):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_contest_metadata("1900")
|
result = scraper.scrape_contest_metadata("1900")
|
||||||
|
|
||||||
assert result.success == True
|
assert result.success
|
||||||
assert len(result.problems) == 2
|
assert len(result.problems) == 2
|
||||||
assert result.problems[0] == ProblemSummary(id="a", name="A. Problem A")
|
assert result.problems[0] == ProblemSummary(id="a", name="A. Problem A")
|
||||||
assert result.problems[1] == ProblemSummary(id="b", name="B. Problem B")
|
assert result.problems[1] == ProblemSummary(id="b", name="B. Problem B")
|
||||||
|
|
@ -56,7 +56,7 @@ def test_scrape_network_error(mocker):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_problem_tests("1900", "A")
|
result = scraper.scrape_problem_tests("1900", "A")
|
||||||
|
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert "network error" in result.error.lower()
|
assert "network error" in result.error.lower()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,7 +80,7 @@ def test_scrape_contests_success(mocker):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_contest_list()
|
result = scraper.scrape_contest_list()
|
||||||
|
|
||||||
assert result.success == True
|
assert result.success
|
||||||
assert len(result.contests) == 3
|
assert len(result.contests) == 3
|
||||||
assert result.contests[0] == ContestSummary(
|
assert result.contests[0] == ContestSummary(
|
||||||
id="1951",
|
id="1951",
|
||||||
|
|
@ -112,7 +112,7 @@ def test_scrape_contests_api_error(mocker):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_contest_list()
|
result = scraper.scrape_contest_list()
|
||||||
|
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert "no contests found" in result.error.lower()
|
assert "no contests found" in result.error.lower()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -127,5 +127,5 @@ def test_scrape_contests_network_error(mocker):
|
||||||
scraper = CodeforcesScraper()
|
scraper = CodeforcesScraper()
|
||||||
result = scraper.scrape_contest_list()
|
result = scraper.scrape_contest_list()
|
||||||
|
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert "network error" in result.error.lower()
|
assert "network error" in result.error.lower()
|
||||||
|
|
|
||||||
|
|
@ -135,17 +135,17 @@ class TestScraperInterfaceCompliance:
|
||||||
|
|
||||||
# Test metadata error format
|
# Test metadata error format
|
||||||
result = scraper.scrape_contest_metadata("test")
|
result = scraper.scrape_contest_metadata("test")
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert result.error.startswith(f"{platform_name}: ")
|
assert result.error.startswith(f"{platform_name}: ")
|
||||||
|
|
||||||
# Test problem tests error format
|
# Test problem tests error format
|
||||||
result = scraper.scrape_problem_tests("test", "A")
|
result = scraper.scrape_problem_tests("test", "A")
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert result.error.startswith(f"{platform_name}: ")
|
assert result.error.startswith(f"{platform_name}: ")
|
||||||
|
|
||||||
# Test contest list error format
|
# Test contest list error format
|
||||||
result = scraper.scrape_contest_list()
|
result = scraper.scrape_contest_list()
|
||||||
assert result.success == False
|
assert not result.success
|
||||||
assert result.error.startswith(f"{platform_name}: ")
|
assert result.error.startswith(f"{platform_name}: ")
|
||||||
|
|
||||||
@pytest.mark.parametrize("scraper_class", ALL_SCRAPER_CLASSES)
|
@pytest.mark.parametrize("scraper_class", ALL_SCRAPER_CLASSES)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue