Skip to content

Commit

Permalink
additional_fields must return an object instead of a string
Browse files Browse the repository at this point in the history
  • Loading branch information
mamico committed Aug 27, 2024
1 parent c86b89b commit 06f3ccc
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/redturtle/prenotazioni/tests/test_prenotazioni_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
from datetime import date
from datetime import timedelta
from io import BytesIO
from freezegun import freeze_time

import openpyxl
import transaction
from dateutil import parser
from freezegun import freeze_time
from plone import api
from plone.app.testing import SITE_OWNER_NAME
from plone.app.testing import SITE_OWNER_PASSWORD
Expand Down Expand Up @@ -714,26 +715,27 @@ def test_additional_fields(self):
{"name": "email", "value": "mario.rossi@example"},
{"name": "fiscalcode", "value": "ABCDEF12G34H567I"},
],
additional_fields=[
{"name": "foo", "value": "bar"}
],
additional_fields=[{"name": "foo", "value": "bar"}],
)
self.assertEqual(res.status_code, 200)
self.assertEqual(
res.json()['additional_fields'],
[{'name': 'foo', 'value': 'bar'}]
res.json()["additional_fields"], [{"name": "foo", "value": "bar"}]
)
booking_code = res.json()["booking_code"]
res = self.api_session.get(
f"{self.portal.absolute_url()}/@bookings?SearchableText={booking_code}"
)
booking_code = res.json()['booking_code']
res = self.api_session.get(f"{self.portal.absolute_url()}/@bookings?SearchableText={booking_code}")
self.assertEqual(res.status_code, 200)
self.assertEqual(res.json()['items_total'], 1)
self.assertEqual(res.json()["items_total"], 1)
self.assertEqual(
res.json()['items'][0]['additional_fields'],
[{'name': 'foo', 'value': 'bar'}]
res.json()["items"][0]["additional_fields"],
[{"name": "foo", "value": "bar"}],
)

# utility methods
def add_booking(self, api_session, booking_date, booking_type, fields, additional_fields=None):
def add_booking(
self, api_session, booking_date, booking_type, fields, additional_fields=None
):
return api_session.post(
f"{self.folder_prenotazioni.absolute_url()}/@booking",
json={
Expand Down

0 comments on commit 06f3ccc

Please sign in to comment.