From 5aa377fde7a93b9b6062450384f9b93af42e721b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 2 Aug 2022 09:00:58 +0200 Subject: [PATCH] tests: add test for card edition API --- tests/api/test_carddef.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/api/test_carddef.py b/tests/api/test_carddef.py index d8b0ca76f..630d30586 100644 --- a/tests/api/test_carddef.py +++ b/tests/api/test_carddef.py @@ -1042,6 +1042,44 @@ def test_formdef_submit_structured(pub, local_user): } +def test_card_edit(pub, local_user): + pub.role_class.wipe() + role = pub.role_class(name='test') + role.store() + local_user.roles = [role.id] + local_user.store() + + ApiAccess.wipe() + access = ApiAccess() + access.name = 'test' + access.access_identifier = 'test' + access.access_key = '12345' + access.store() + + access.roles = [role] + access.store() + + CardDef.wipe() + carddef = CardDef() + carddef.name = 'test' + carddef.fields = [fields.StringField(id='0', label='foobar', varname='foobar')] + carddef.workflow_roles = {'_editor': role.id} + carddef.store() + + data_class = carddef.data_class() + carddata = data_class() + carddata.data = {'0': 'foobar'} + carddata.just_created() + carddata.store() + + app = get_app(pub) + app.set_authorization(('Basic', ('test', '12345'))) + resp = app.post_json(carddata.get_api_url(), {'data': {'foobar': 'baz'}}) + assert resp.json['err'] == 0 + carddata.refresh_from_storage() + assert carddata.data == {'0': 'baz'} + + def test_card_parent_form_url(pub, local_user): pub.role_class.wipe() role = pub.role_class(name='test')