fix(test): update scrapers
This commit is contained in:
parent
7d8d00c5ad
commit
e7ba6b4bb4
4 changed files with 37 additions and 14 deletions
|
|
@ -314,16 +314,23 @@ class AtcoderScraper(BaseScraper):
|
||||||
return
|
return
|
||||||
data = await asyncio.to_thread(_scrape_problem_page_sync, category_id, slug)
|
data = await asyncio.to_thread(_scrape_problem_page_sync, category_id, slug)
|
||||||
tests: list[TestCase] = data.get("tests", [])
|
tests: list[TestCase] = data.get("tests", [])
|
||||||
|
combined_input = "\n".join(t.input for t in tests) if tests else ""
|
||||||
|
combined_expected = "\n".join(t.expected for t in tests) if tests else ""
|
||||||
print(
|
print(
|
||||||
json.dumps(
|
json.dumps(
|
||||||
{
|
{
|
||||||
"problem_id": letter,
|
"problem_id": letter,
|
||||||
|
"combined": {
|
||||||
|
"input": combined_input,
|
||||||
|
"expected": combined_expected,
|
||||||
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{"input": t.input, "expected": t.expected} for t in tests
|
{"input": t.input, "expected": t.expected} for t in tests
|
||||||
],
|
],
|
||||||
"timeout_ms": data.get("timeout_ms", 0),
|
"timeout_ms": data.get("timeout_ms", 0),
|
||||||
"memory_mb": data.get("memory_mb", 0),
|
"memory_mb": data.get("memory_mb", 0),
|
||||||
"interactive": bool(data.get("interactive")),
|
"interactive": bool(data.get("interactive")),
|
||||||
|
"multi_test": False,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
flush=True,
|
flush=True,
|
||||||
|
|
|
||||||
|
|
@ -231,14 +231,24 @@ class CodeChefScraper(BaseScraper):
|
||||||
memory_mb = 256.0
|
memory_mb = 256.0
|
||||||
interactive = False
|
interactive = False
|
||||||
|
|
||||||
|
combined_input = "\n".join(t.input for t in tests) if tests else ""
|
||||||
|
combined_expected = (
|
||||||
|
"\n".join(t.expected for t in tests) if tests else ""
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"problem_id": problem_code,
|
"problem_id": problem_code,
|
||||||
|
"combined": {
|
||||||
|
"input": combined_input,
|
||||||
|
"expected": combined_expected,
|
||||||
|
},
|
||||||
"tests": [
|
"tests": [
|
||||||
{"input": t.input, "expected": t.expected} for t in tests
|
{"input": t.input, "expected": t.expected} for t in tests
|
||||||
],
|
],
|
||||||
"timeout_ms": timeout_ms,
|
"timeout_ms": timeout_ms,
|
||||||
"memory_mb": memory_mb,
|
"memory_mb": memory_mb,
|
||||||
"interactive": interactive,
|
"interactive": interactive,
|
||||||
|
"multi_test": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks = [run_one(problem_code) for problem_code in problems.keys()]
|
tasks = [run_one(problem_code) for problem_code in problems.keys()]
|
||||||
|
|
|
||||||
|
|
@ -235,8 +235,10 @@ class CSESScraper(BaseScraper):
|
||||||
tests = []
|
tests = []
|
||||||
timeout_ms, memory_mb, interactive = 0, 0, False
|
timeout_ms, memory_mb, interactive = 0, 0, False
|
||||||
|
|
||||||
combined_input = "\n".join(t.input for t in tests)
|
combined_input = "\n".join(t.input for t in tests) if tests else ""
|
||||||
combined_expected = "\n".join(t.expected for t in tests)
|
combined_expected = (
|
||||||
|
"\n".join(t.expected for t in tests) if tests else ""
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"problem_id": pid,
|
"problem_id": pid,
|
||||||
|
|
@ -250,6 +252,7 @@ class CSESScraper(BaseScraper):
|
||||||
"timeout_ms": timeout_ms,
|
"timeout_ms": timeout_ms,
|
||||||
"memory_mb": memory_mb,
|
"memory_mb": memory_mb,
|
||||||
"interactive": interactive,
|
"interactive": interactive,
|
||||||
|
"multi_test": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks = [run_one(p.id) for p in problems]
|
tasks = [run_one(p.id) for p in problems]
|
||||||
|
|
|
||||||
|
|
@ -55,18 +55,21 @@ def test_scraper_offline_fixture_matrix(run_scraper_offline, scraper, mode):
|
||||||
else:
|
else:
|
||||||
assert len(model.contests) >= 1
|
assert len(model.contests) >= 1
|
||||||
else:
|
else:
|
||||||
|
assert len(objs) >= 1, "No test objects returned"
|
||||||
validated_any = False
|
validated_any = False
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
if "success" in obj and "tests" in obj and "problem_id" in obj:
|
assert "problem_id" in obj, "Missing problem_id"
|
||||||
tr = TestsResult.model_validate(obj)
|
assert obj["problem_id"] != "", "Empty problem_id"
|
||||||
assert tr.problem_id != ""
|
assert "combined" in obj, "Missing combined field"
|
||||||
assert isinstance(tr.tests, list)
|
assert isinstance(obj["combined"], dict), "combined must be a dict"
|
||||||
validated_any = True
|
assert "input" in obj["combined"], "Missing combined.input"
|
||||||
else:
|
assert "expected" in obj["combined"], "Missing combined.expected"
|
||||||
assert "problem_id" in obj
|
assert "tests" in obj, "Missing tests field"
|
||||||
assert "tests" in obj and isinstance(obj["tests"], list)
|
assert isinstance(obj["tests"], list), "tests must be a list"
|
||||||
assert (
|
assert "timeout_ms" in obj, "Missing timeout_ms"
|
||||||
"timeout_ms" in obj and "memory_mb" in obj and "interactive" in obj
|
assert "memory_mb" in obj, "Missing memory_mb"
|
||||||
)
|
assert "interactive" in obj, "Missing interactive"
|
||||||
validated_any = True
|
assert "multi_test" in obj, "Missing multi_test field"
|
||||||
|
assert isinstance(obj["multi_test"], bool), "multi_test must be bool"
|
||||||
|
validated_any = True
|
||||||
assert validated_any, "No valid tests payloads validated"
|
assert validated_any, "No valid tests payloads validated"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue