Internal Server Error at API call for paged dates of an event #365

This commit is contained in:
Daniel Grams 2022-03-09 19:20:30 +01:00
parent b6e2182a61
commit f652620617
5 changed files with 23 additions and 5 deletions

View File

@ -146,7 +146,7 @@ class EventDatesResource(BaseResource):
@use_kwargs(EventDateListRequestSchema, location=("query"))
@marshal_with(EventDateListResponseSchema)
@require_oauth(optional=True)
def get(self, id):
def get(self, id, **kwargs):
event = Event.query.options(
load_only(Event.id, Event.public_status)
).get_or_404(id)

View File

@ -460,13 +460,15 @@ class LdJsonImporter:
if isinstance(value, dict):
result = dict()
for k, v in value.items():
result[k] = self._strip_ld_json(v)
if v:
result[k] = self._strip_ld_json(v)
return result
if isinstance(value, list):
result = list()
for elem in value:
result.append(self._strip_ld_json(elem))
if elem:
result.append(self._strip_ld_json(elem))
return result
return value

View File

@ -128,6 +128,14 @@ def test_dates(client, seeder, utils):
response = utils.get(url)
utils.assert_response_unauthorized(response)
event_id = seeder.create_event(
admin_unit_id, recurrence_rule="RRULE:FREQ=DAILY;COUNT=51"
)
url = utils.get_url("api_v1_event_dates", id=event_id)
utils.get_ok(url)
url = utils.get_url("api_v1_event_dates", id=event_id, page=2)
utils.get_ok(url)
def test_dates_myDraft(client, seeder, utils):
user_id, admin_unit_id = seeder.setup_api_access()

View File

@ -2,7 +2,7 @@ import pytest
# Load more urls:
# curl -o tests/services/importer/test_event_importer/<filename>.html <URL>
# curl -o tests/services/importer/data/<filename>.html <URL>
def test_import(client, seeder, utils, app, shared_datadir, requests_mock):
_, admin_unit_id = seeder.setup_base()
seeder.upsert_event_place(admin_unit_id, "MINER'S ROCK")

View File

@ -42,6 +42,14 @@ class TestLdJsonImporter(SubTests):
event = self._load_event_from_ld_json(manipulate)
assert event is not None
def _test_null_organizer_but_author(self):
def manipulate(ld_json):
ld_json["author"] = ld_json["organizer"]
ld_json["organizer"] = [None]
event = self._load_event_from_ld_json(manipulate)
assert event is not None
def _test_no_organizer(self):
import pytest
@ -90,7 +98,7 @@ class TestLdJsonImporter(SubTests):
manipulate_json(ld_json)
importer = LdJsonImporter("", "")
importer.ld_json = ld_json
importer.ld_json = importer._strip_ld_json(ld_json)
event = importer.load_event_from_ld_json()
return event