On Fri, 2011-04-15 at 15:39 -0700, mdob wrote:
> Just like in the title. I have a model and I can test in manually in a
> browser. I enter url in a browser and receive a result form one of the
> views. Thing is unittest should be doing that. Functional test isn't
> exactly what is needed. Because I want to check only if traversal in
> my application return a correct context.
>
> I think there should be some way to create a request, send it to the
> application and in return receive the context.
from pyramid.traversal import traverse
D = traverse(root, '/some/path')
context = D['context']
"root" has to come from somewhere though. The most heavy-handed way to
get one is to use the pyramid.scripting.get_root API:
from pyramid.paster import get_app
from pyramid.paster import get_root
app = get_app('/path/to/development.ini', 'myapp')
root = get_root(app)
What'd you be testing here is that the resource tree represented by the
root object you're returning has the right composition. This is a bit
of a strange unit test, because usually a unit test tests your code, and
not the framework code, and it's uncommon to test that a resource tree
is composed of exactly some object at some path (the resource tree often
changes over time).
- C
--
You received this message because you are subscribed to the Google Groups
"pylons-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-devel?hl=en.