diff --git a/openstates/scrape/schemas/event.py b/openstates/scrape/schemas/event.py index e0f94139..6858811b 100644 --- a/openstates/scrape/schemas/event.py +++ b/openstates/scrape/schemas/event.py @@ -67,9 +67,18 @@ "items": { "properties": { "note": {"type": "string", "minLength": 1}, - "url": {"type": "string", "minLength": 1}, - "media_type": {"type": "string", "minLength": 1}, "date": fuzzy_date_blank, + "classification": {"type": "string"}, + "links": { + "items": { + "properties": { + "media_type": {"type": "string"}, + "url": {"type": "string", "format": "uri"}, + }, + "type": "object", + }, + "type": "array", + }, }, "type": "object", }, diff --git a/openstates/scrape/tests/test_event_scrape.py b/openstates/scrape/tests/test_event_scrape.py index 8ff5abe4..3038358b 100644 --- a/openstates/scrape/tests/test_event_scrape.py +++ b/openstates/scrape/tests/test_event_scrape.py @@ -125,6 +125,24 @@ def test_add_document(): e.validate() +def test_add_document_rejects_bad_url(): + # Regression for openstates/issues#1298: the schema treated document + # urls as plain strings, so a relative path like "/whatever/124.html" + # silently passed validation. The url should now have to be a real URI. + import pytest + + from openstates.exceptions import ScrapeValueError + + e = event_obj() + e.add_document( + note="hello", + url="/whatever/124.html", + media_type="text/html", + ) + with pytest.raises(ScrapeValueError): + e.validate() + + def test_participants(): e = event_obj() e.add_participant("Committee of the Whole", type="committee", note="everyone")