Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test helper function for posting to CKAN API
Add ckan.tests.post(), a helper function for posting to CKAN's action API and getting the result, that handles forming the correct action API URL, converting the apikey to a string and putting it in a headers dict like TestApp expects, collecting params into a dict and dumping them to a JSON string, and checking the 'success' field of the response. This can save a lot of lines of code and make tests more readable. I've converted test_follow.py as an example of how much can be saved. Similar savings could be made in many other test modules: ckan/tests/functional/api/model/test_vocabulary.py, ckan/tests/functional/api/model/test_group.py, ckan/tests/functional/api/test_dashboard.py, ckan/tests/functional/api/test_activity.py, ckan/tests/functional/test_follow.py, ckan/tests/functional/test_tag_vocab.py, ckan/tests/functional/test_related.py, ckan/tests/logic/test_action.py ckan/tests/logic/test_tag.py. ckan/tests/functional/api/model/test_package.py could also be changed to use this function. It currently uses a similar function defined in ckan.tests.functional.api.base:ApiTestCase.
- Loading branch information