[ckan-changes] [okfn/ckan] a4d88b: [#642] Inject `error_handler` instead of explicitl...

GitHub noreply at github.com
Wed Apr 3 09:17:17 UTC 2013


  Branch: refs/heads/718-datastore-depends-on-localisation-for-2.0
  Home:   https://github.com/okfn/ckan
  Commit: a4d88b756c90c794f7f3473b319d386182d74ce8
      https://github.com/okfn/ckan/commit/a4d88b756c90c794f7f3473b319d386182d74ce8
  Author: Dominik Moritz <domoritz at gmail.com>
  Date:   2013-04-03 (Wed, 03 Apr 2013)

  Changed paths:
    M ckanext/datastore/plugin.py
    M ckanext/datastore/tests/test_configure.py

  Log Message:
  -----------
  [#642] Inject `error_handler` instead of explicitly passing it as an argument, split large test into smaller tests


  Commit: d76c6570fe96e64925ff7d847e5a0e561ea5be55
      https://github.com/okfn/ckan/commit/d76c6570fe96e64925ff7d847e5a0e561ea5be55
  Author: Dominik Moritz <domoritz at gmail.com>
  Date:   2013-04-03 (Wed, 03 Apr 2013)

  Changed paths:
    M ckanext/datastore/tests/test_configure.py

  Log Message:
  -----------
  [#642] Add plugin loading and unloading. This does not fix the singleton issue but is better anyway.


  Commit: 705c39e45ced0ab79567df357f891ad76753a5a8
      https://github.com/okfn/ckan/commit/705c39e45ced0ab79567df357f891ad76753a5a8
  Author: Dominik Moritz <domoritz at gmail.com>
  Date:   2013-04-03 (Wed, 03 Apr 2013)

  Changed paths:
    M ckanext/datastore/db.py
    M ckanext/datastore/plugin.py

  Log Message:
  -----------
  [#642] Use single quotes where possible


  Commit: 3c60da1e540a1258f1c54b1c43f6c221e0edbf6f
      https://github.com/okfn/ckan/commit/3c60da1e540a1258f1c54b1c43f6c221e0edbf6f
  Author: Vitor Baptista <vitor at vitorbaptista.com>
  Date:   2013-04-03 (Wed, 03 Apr 2013)

  Changed paths:
    M ckanext/datastore/tests/test_configure.py

  Log Message:
  -----------
  [#642] Refactor and fix Datastore tests

Datastore is a SingletonPlugin, so it doesn't matter if we call
plugin.DatastorePlugin() many times: we always end up with the same instance.
I've added a workaround that, first, saves and unloads the current datastore
instance, then sets:

  pyutilib.component.core.PluginGlobals.singleton_services()[plugin.DatastorePlugin] = True

This will make plugin.DatastorePlugin not be a Singleton anymore, so any
subsequent calls to ckan.plugins.load('datastore') will create a new instance.
Then, in the next line, we create a new DatastorePlugin instance by loading
it, and save it into self.p and
pyutilib.component.core.PluginGlobals.singleton_services()[plugin.DatastorePlugin].
This turns DatastorePlugin into a Singleton again, and subsequent calls to
ckan.plugins.load('datastore') will return this new instance instead.

Then, in the teardown, we unload the current the datastore, which gets rid of
our test instance, and put the original datastore back in its place, so the
environment before setUp() is the same as after tearDown().

For InvalidUrlsOrPermissionsException, what I wanted was a way to check if
_check_urls_and_permissions() failed. I did this by overloading _log_or_raise()
with an unique Exception, and checking if it's raised. If so, I guarantee that
_log_or_raise() was called. This feels like too much boilerplate, but we don't
have a stub/mock library, so we have to write it.

Conflicts:
	ckanext/datastore/tests/test_configure.py


  Commit: 09b23ddeb60b25aaed97f538c23e411b11292b30
      https://github.com/okfn/ckan/commit/09b23ddeb60b25aaed97f538c23e411b11292b30
  Author: Dominik Moritz <domoritz at gmail.com>
  Date:   2013-04-03 (Wed, 03 Apr 2013)

  Changed paths:
    M ckanext/datastore/tests/test_configure.py

  Log Message:
  -----------
  [#642] PEP8


Compare: https://github.com/okfn/ckan/compare/38ea5c6572de...09b23ddeb60b


More information about the ckan-changes mailing list