tests: add test for card edition API
This commit is contained in:
parent
2444b25968
commit
5aa377fde7
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue