-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Assign is_complex automatically to custom form (#7086)
- Loading branch information
1 parent
5901e1f
commit 0f00132
Showing
4 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
81 changes: 81 additions & 0 deletions
81
tests/all/integration/api/custom_forms/test_custom_forms_api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import json | ||
|
||
from app.models.custom_form import CustomForms | ||
from tests.factories.event import EventFactoryBasic | ||
|
||
|
||
def test_custom_form_create(db, client, user, jwt): | ||
user.is_super_admin = True | ||
event = EventFactoryBasic(owner=user) | ||
db.session.commit() | ||
|
||
data = json.dumps( | ||
{ | ||
'data': { | ||
'type': 'custom-form', | ||
"attributes": { | ||
"form": "attendee", | ||
"type": "email", | ||
"field-identifier": "email", | ||
"name": "Email", | ||
"is-included": True, | ||
"is-required": True, | ||
"is-complex": True, | ||
}, | ||
"relationships": { | ||
"event": {"data": {"id": str(event.id), "type": "event"}} | ||
}, | ||
} | ||
} | ||
) | ||
|
||
response = client.post( | ||
'/v1/custom-forms', | ||
content_type='application/vnd.api+json', | ||
headers=jwt, | ||
data=data, | ||
) | ||
|
||
assert response.status_code == 201 | ||
c_id = json.loads(response.data)['data']['id'] | ||
custom_form = CustomForms.query.get(c_id) | ||
|
||
assert custom_form.form == 'attendee' | ||
assert custom_form.type == 'email' | ||
assert custom_form.field_identifier == 'email' | ||
assert custom_form.is_complex is False | ||
|
||
data = json.dumps( | ||
{ | ||
'data': { | ||
'type': 'custom-form', | ||
"attributes": { | ||
"form": "attendee", | ||
"type": "number", | ||
"field-identifier": "vortexTensor", | ||
"name": "Vortex Tensor", | ||
"is-included": True, | ||
"is-required": True, | ||
}, | ||
"relationships": { | ||
"event": {"data": {"id": str(event.id), "type": "event"}} | ||
}, | ||
} | ||
} | ||
) | ||
|
||
response = client.post( | ||
'/v1/custom-forms', | ||
content_type='application/vnd.api+json', | ||
headers=jwt, | ||
data=data, | ||
) | ||
|
||
assert response.status_code == 201 | ||
c_id = json.loads(response.data)['data']['id'] | ||
custom_form = CustomForms.query.get(c_id) | ||
|
||
assert custom_form.form == 'attendee' | ||
assert custom_form.type == 'number' | ||
assert custom_form.identifier == 'vortex_tensor' | ||
assert custom_form.is_complex is True |