Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion app/api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def validate_event(user, data):

if not data.get('name', None) and data.get('state', None) == 'published':
raise ConflictError(
{'pointer': '/data/attributes/location-name'},
{'pointer': '/data/attributes/name'},
"Event Name is required to publish the event",
)

Expand Down
1 change: 0 additions & 1 deletion app/api/schema/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from utils.common import use_defaults


@use_defaults()
class EventSchemaPublic(SoftDeletionSchema):
class Meta:
type_ = 'event'
Expand Down
Empty file.
67 changes: 67 additions & 0 deletions tests/all/integration/api/event/test_event_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import json

from tests.factories.event import EventFactoryBasic


def get_event(db):
event = EventFactoryBasic(location_name='Amsterdam')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Black would make changes.

db.session.commit()

return event


def test_edit_event_default_field(db, client, admin_jwt):
# Should let the previous value remain unchanged if field is not present in data
event = get_event(db)

data = json.dumps(
{
'data': {
'type': 'event',
'id': str(event.id),
'attributes': {'timezone': 'Europe/Berlin'},
}
}
)

response = client.patch(
f'/v1/events/{event.id}',
content_type='application/vnd.api+json',
headers=admin_jwt,
data=data,
)

db.session.refresh(event)

assert response.status_code == 200
assert event.location_name == 'Amsterdam'
assert event.timezone == 'Europe/Berlin'


def test_edit_event_null_field(db, client, admin_jwt):
# Should let the previous value be nulled if field is null in data
event = get_event(db)

assert event.location_name == 'Amsterdam'

data = json.dumps(
{
'data': {
'type': 'event',
'id': str(event.id),
'attributes': {'location-name': None},
}
}
)

response = client.patch(
f'/v1/events/{event.id}',
content_type='application/vnd.api+json',
headers=admin_jwt,
data=data,
)

db.session.refresh(event)

assert response.status_code == 200
assert event.location_name is None