Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions openstates/scrape/schemas/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
18 changes: 18 additions & 0 deletions openstates/scrape/tests/test_event_scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down