You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/01/06 16:18:39 UTC
[49/50] git commit: [#6896] Update test example;
comment merge instructions
[#6896] Update test example; comment merge instructions
Signed-off-by: Tim Van Steenburgh <tv...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/18e8da13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/18e8da13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/18e8da13
Branch: refs/heads/cj/6992
Commit: 18e8da1353fd5c138fa4d6b00a659e6629c69214
Parents: d09e21d
Author: Tim Van Steenburgh <tv...@gmail.com>
Authored: Thu Jan 2 22:09:13 2014 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Thu Jan 2 18:22:16 2014 -0500
----------------------------------------------------------------------
Allura/docs/contributing.rst | 23 +++++++++++++----------
Allura/docs/tutorials/testing.rst | 24 ++++++++++++++----------
2 files changed, 27 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/18e8da13/Allura/docs/contributing.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/contributing.rst b/Allura/docs/contributing.rst
index e6ed088..ac956eb 100644
--- a/Allura/docs/contributing.rst
+++ b/Allura/docs/contributing.rst
@@ -193,13 +193,16 @@ When writing code for Allura, don't forget that you'll need to also create
tests that cover behaviour that you've added or changed. You may find this
:doc:`short guide <tutorials/testing>` helpful.
-Submitting a Merge Request
---------------------------
-Before submitting a merge request, make sure your changes conform to our
-`contribution guidelines <https://forge-allura.apache.org/p/allura/wiki/Contributing%20Code/>`_.
-Once your changes are finished and tested, submit them to be merged back into
-the main repo:
-
-* Fork the main Allura repo from here: https://forge-allura.apache.org/p/allura/git/ci/master/tree/
-* Commit and push your changes to your fork
-* Submit a Merge Request from your fork
+.. Commenting out merge request instructions until we have forking working
+ on forge-allura.apache.org
+
+ Submitting a Merge Request
+ --------------------------
+ Before submitting a merge request, make sure your changes conform to our
+ `contribution guidelines <https://forge-allura.apache.org/p/allura/wiki/Contributing%20Code/>`_.
+ Once your changes are finished and tested, submit them to be merged back into
+ the main repo:
+
+ * Fork the main Allura repo from here: https://forge-allura.apache.org/p/allura/git/ci/master/tree/
+ * Commit and push your changes to your fork
+ * Submit a Merge Request from your fork
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/18e8da13/Allura/docs/tutorials/testing.rst
----------------------------------------------------------------------
diff --git a/Allura/docs/tutorials/testing.rst b/Allura/docs/tutorials/testing.rst
index b1164a5..646a24e 100644
--- a/Allura/docs/tutorials/testing.rst
+++ b/Allura/docs/tutorials/testing.rst
@@ -49,21 +49,25 @@ The framework used to generate the WSGI environment for testing your tools is
provided by the `WebTest <http://pythonpaste.org/webtest/>`_ module, where you can
find further documentation for the `.get()` and `.post()` methods.
-Testing Allura models is also straightforward, though it usually requires
-setting the pylons context object `c` before your test. An example of this
-technique follows::
+Testing Allura models is also straightforward, though you will often
+need to setup pylons global objects before your test. If the code under test
+uses pylons globals (like `g` and `c`), but your test doesn't require the
+fully-loaded wsgi app, you can do something like this:
- import mock
- from pylons import tmpl_context as c, app_globals as g
+.. code-block:: python
- from allura.lib.app_globals import Globals
+ from pylons import tmpl_context as c
+
+ from alluratest.controller import setup_unit_test
+ from allura.lib import helpers a h
from allura import model as M
def setUp():
- g._push_object(Globals())
- c._push_object(mock.Mock())
- g.set_project('projects/test')
- g.set_app('hello')
+ # set up pylons globals
+ setup_unit_test()
+
+ # set c.project and c.app
+ h.set_context('test', 'wiki', neighborhood='Projects'):
c.user = M.User.query.get(username='test-admin')
Testing the tasks and events is similar to testing models. Generally, you will