tests: test categories API

This commit is contained in:
Frédéric Péters 2014-12-25 11:32:47 +01:00
parent f25303c3ec
commit 14236af269
1 changed files with 21 additions and 5 deletions

View File

@ -33,11 +33,6 @@ def setup_module(module):
coucou = 1234
''')
category = Category()
category.name = 'category'
category.store()
def teardown_module(module):
global pub
shutil.rmtree(pub.APP_DIR)
@ -147,3 +142,24 @@ def test_formdef_schema():
resp = get_app(pub).get('/test/schema')
assert resp.json['name'] == 'test'
assert resp.json['fields'][0]['label'] == 'foobar'
def test_categories():
Category.wipe()
category = Category()
category.name = 'category'
category.description = 'hello world'
category.store()
resp = get_app(pub).get('/categories', headers={'Accept': 'application/json'})
assert resp.json['data'] == [] # no advertised forms
FormDef.wipe()
formdef = FormDef()
formdef.name = 'test'
formdef.category_id = category.id
formdef.store()
resp = get_app(pub).get('/categories', headers={'Accept': 'application/json'})
assert resp.json['data'][0]['title'] == 'category'
assert resp.json['data'][0]['url'] == 'http://example.net/category/'
assert resp.json['data'][0]['description'] == 'hello world'