[ckan-changes] [ckan/ckan] e67053: [#3760] Auto generate a Flask test request context...

GitHub noreply at github.com
Wed Aug 23 14:42:14 UTC 2017


  Branch: refs/heads/3760-auto-test-request-context
  Home:   https://github.com/ckan/ckan
  Commit: e6705332fac5b0c97f6ac657887e525d9e07ca51
      https://github.com/ckan/ckan/commit/e6705332fac5b0c97f6ac657887e525d9e07ca51
  Author: amercader <amercadero at gmail.com>
  Date:   2017-08-23 (Wed, 23 Aug 2017)

  Changed paths:
    M ckan/config/middleware/__init__.py
    M ckan/lib/cli.py
    M ckan/lib/helpers.py

  Log Message:
  -----------
  [#3760] Auto generate a Flask test request context when calling url_for

This is an attempt to try to avoid having to explicitly generate a Flask
request context on all tests that involve url_for.

There are two scenarios when url_for is called outside the context of a
web request: tests and CLI.

The idea is to provide a fallback test request context on url_for if there
isn't one available. On tests, we have the added complexity that tests can
modify the configuration and plugins loaded so we can't reuse the same.

This is an ugly patch, as it uses to global variables. For CLI commands
there's a test request context created on `load_config`, which all
commands should run on startup.

For tests, the only safe place to create it is at the lowest level, on
`make_app`, as soon as the environment is loaded and there is a Flask
app available. Of course this only works if the tests create a test web
app, but that is the most common scenario (eg `FunctionalTestBase` or
any test that creates its own app).

Other tests can create their own test request context if needeed.


  Commit: 88711e9a3c2f0f9a772cf646570a95f33165f642
      https://github.com/ckan/ckan/commit/88711e9a3c2f0f9a772cf646570a95f33165f642
  Author: amercader <amercadero at gmail.com>
  Date:   2017-08-23 (Wed, 23 Aug 2017)

  Changed paths:
    M ckan/tests/controllers/test_package.py
    M ckan/tests/legacy/__init__.py
    M ckan/tests/legacy/functional/api/base.py
    M ckan/tests/legacy/functional/api/model/test_package.py
    M ckan/tests/legacy/functional/api/model/test_relationships.py
    M ckan/tests/legacy/functional/api/model/test_vocabulary.py
    M ckan/tests/legacy/functional/api/test_activity.py
    M ckan/tests/legacy/functional/api/test_dashboard.py
    M ckan/tests/legacy/functional/api/test_email_notifications.py
    M ckan/tests/legacy/functional/api/test_follow.py
    M ckan/tests/legacy/functional/api/test_resource.py
    M ckan/tests/legacy/functional/api/test_user.py
    M ckan/tests/legacy/functional/api/test_util.py
    M ckan/tests/legacy/functional/test_activity.py
    M ckan/tests/legacy/functional/test_admin.py
    M ckan/tests/legacy/functional/test_group.py
    M ckan/tests/legacy/functional/test_package.py
    M ckan/tests/legacy/functional/test_pagination.py
    M ckan/tests/legacy/functional/test_preview_interface.py
    M ckan/tests/legacy/functional/test_revision.py
    M ckan/tests/legacy/functional/test_tag.py
    M ckan/tests/legacy/functional/test_tracking.py
    M ckan/tests/legacy/functional/test_user.py
    M ckan/tests/legacy/html_check.py
    M ckan/tests/legacy/lib/test_alphabet_pagination.py
    M ckan/tests/legacy/logic/test_action.py
    M ckan/tests/legacy/logic/test_auth.py
    M ckan/tests/legacy/misc/test_format_text.py
    M ckan/tests/legacy/models/test_package.py
    M ckan/tests/legacy/test_coding_standards.py

  Log Message:
  -----------
  Revert "[#3196] Fix legacy tests dependant on url_for"

This reverts commit 2d83e0d1366a76c8f83fd316301b9976f38fab62.


  Commit: 282092d2c6be89131e59afb2b296bdddaaf6b9bd
      https://github.com/ckan/ckan/commit/282092d2c6be89131e59afb2b296bdddaaf6b9bd
  Author: amercader <amercadero at gmail.com>
  Date:   2017-08-23 (Wed, 23 Aug 2017)

  Changed paths:
    M ckan/lib/alphabet_paginate.py
    M ckan/tests/config/test_middleware.py
    M ckan/tests/controllers/test_admin.py
    M ckan/tests/controllers/test_api.py
    M ckan/tests/controllers/test_feed.py
    M ckan/tests/controllers/test_group.py
    M ckan/tests/controllers/test_home.py
    M ckan/tests/controllers/test_organization.py
    M ckan/tests/controllers/test_package.py
    M ckan/tests/controllers/test_tags.py
    M ckan/tests/controllers/test_user.py
    M ckan/tests/controllers/test_util.py
    M ckan/tests/lib/test_helpers.py
    M ckan/tests/lib/test_mailer.py
    M ckan/tests/logic/action/test_create.py

  Log Message:
  -----------
  Revert "[#3196] Fix ckan/ tests (no legacy) depending on url_for"

This reverts commit 43767c78390f389b62767f7e38cfdba7d68a958b.


  Commit: c38c7dde2272de535fcb8682472388c03ef68163
      https://github.com/ckan/ckan/commit/c38c7dde2272de535fcb8682472388c03ef68163
  Author: amercader <amercadero at gmail.com>
  Date:   2017-08-23 (Wed, 23 Aug 2017)

  Changed paths:
    M ckanext/datapusher/tests/test.py
    M ckanext/datapusher/tests/test_interfaces.py
    M ckanext/datastore/tests/test_create.py
    M ckanext/datastore/tests/test_delete.py
    M ckanext/datastore/tests/test_dump.py
    M ckanext/datastore/tests/test_search.py
    M ckanext/datastore/tests/test_upsert.py
    M ckanext/example_idatasetform/tests/test_controllers.py
    M ckanext/example_igroupform/tests/test_controllers.py
    M ckanext/example_iresourcecontroller/tests/test_example_iresourcecontroller.py
    M ckanext/example_itranslation/tests/test_plugin.py
    M ckanext/example_iuploader/test/test_plugin.py
    M ckanext/imageview/tests/test_view.py
    M ckanext/multilingual/tests/test_multilingual_plugin.py
    M ckanext/reclineview/tests/test_view.py
    M ckanext/resourceproxy/tests/test_proxy.py
    M ckanext/stats/tests/__init__.py
    M ckanext/stats/tests/test_stats_plugin.py
    M ckanext/textview/tests/test_view.py
    M ckanext/webpageview/tests/test_view.py

  Log Message:
  -----------
  Revert "[#3196] Fix ckanext tests dependant on url_for"

This reverts commit 22cb37d62841771481d1567323a7b0d6ea1949e9.


  Commit: 28caf7ded72cc3ba638269809b63c49007228c73
      https://github.com/ckan/ckan/commit/28caf7ded72cc3ba638269809b63c49007228c73
  Author: amercader <amercadero at gmail.com>
  Date:   2017-08-23 (Wed, 23 Aug 2017)

  Changed paths:
    M ckan/tests/controllers/test_user.py
    M ckan/tests/legacy/test_coding_standards.py
    M ckan/tests/lib/test_helpers.py
    M ckan/tests/test_none_root.py

  Log Message:
  -----------
  [#3760] Fix some more tests after reversing context changes


Compare: https://github.com/ckan/ckan/compare/e6705332fac5^...28caf7ded72c


More information about the ckan-changes mailing list