| incomplete",
"config": {"strategy": "default"}
})
# Should handle gracefully (either return empty or partial results)
assert response.status_code in [200, 400, 500]
def test_empty_html(self, server_url, wait_for_server):
"""Test handling of empty HTML"""
response = requests.post(f"{server_url}/tables/extract", json={
"html": "",
"config": {"strategy": "default"}
})
# May be rejected as invalid or processed as empty
assert response.status_code in [200, 400]
if response.status_code == 200:
data = response.json()
assert data["table_count"] == 0
def test_html_without_tables(self, server_url, wait_for_server):
"""Test HTML with no tables"""
response = requests.post(f"{server_url}/tables/extract", json={
"html": " No tables here ",
"config": {"strategy": "default"}
})
assert response.status_code == 200
data = response.json()
assert data["table_count"] == 0
def test_invalid_strategy(self, server_url, wait_for_server):
"""Test invalid strategy name"""
response = requests.post(f"{server_url}/tables/extract", json={
"html": SAMPLE_HTML_WITH_TABLES,
"config": {"strategy": "invalid_strategy"}
})
# Should return validation error (400 or 422 from Pydantic)
assert response.status_code in [400, 422]
def test_missing_config(self, server_url, wait_for_server):
"""Test missing configuration"""
response = requests.post(f"{server_url}/tables/extract", json={
"html": SAMPLE_HTML_WITH_TABLES
# Missing config
})
# Should use default config or return error
assert response.status_code in [200, 400]
# Run tests
if __name__ == "__main__":
pytest.main([__file__, "-v"])
|