[ckan-changes] [okfn/ckan] 3ea181: Add test helper function for posting to CKAN API

GitHub noreply at github.com
Thu Nov 29 11:32:56 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: 3ea18168e62ae887d38a2d46948434d8b60ebe66
      https://github.com/okfn/ckan/commit/3ea18168e62ae887d38a2d46948434d8b60ebe66
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-11-29 (Thu, 29 Nov 2012)

  Changed paths:
    M ckan/tests/__init__.py
    M ckan/tests/functional/api/test_follow.py

  Log Message:
  -----------
  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.


  Commit: 740a0d887021abad60324ad421f06c36ffaa6f93
      https://github.com/okfn/ckan/commit/740a0d887021abad60324ad421f06c36ffaa6f93
  Author: Sean Hammond <seanhammond at lavabit.com>
  Date:   2012-11-29 (Thu, 29 Nov 2012)

  Changed paths:
    M ckan/tests/__init__.py
    M ckan/tests/functional/api/test_follow.py

  Log Message:
  -----------
  Rename post -> call_action_api

More descriptive name


Compare: https://github.com/okfn/ckan/compare/53013843af36...740a0d887021


More information about the ckan-changes mailing list