Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Testing question
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Toni Mueller  
View profile  
 More options Jun 22 2012, 5:10 pm
From: Toni Mueller <d...@tonimueller.org>
Date: Fri, 22 Jun 2012 23:10:06 +0200
Local: Fri, Jun 22 2012 5:10 pm
Subject: Testing question

Hi,

I want to test a view, but the matchdict doesn't get set up. The
application works when I use it via a web browser.

The route configuration:

    config.add_route('newsletter_create_issue', '%s/createissue/{templateid}' % root_path)

In the test case (the test suite is set up with their own registry):

    def test_getting_an_issue_list(self):
        from pyramid import request
        # the same code is in the route configuration, with the number being
        # a parameter in that view:
        path = '/' + root_path + '/createissue/1'
        req = request.Request.blank(path)
        req.registry = self.config.registry
        # The following bails out, due to the code shown below:
        result = getNewsletterIssues(req, 1) # BOOM!

def getNewsletterIssues(request, id_):
    ...
    tid = int(request.matchdict['templateid'])

The traceback:

...
    tid = int(request.matchdict['templateid'])
TypeError: 'NoneType' object is unsubscriptable

What am I doing wrong?

TIA!

Kind regards,
--Toni++


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe Dallago  
View profile  
 More options Jun 22 2012, 5:37 pm
From: Joe Dallago <jd.dall...@gmail.com>
Date: Fri, 22 Jun 2012 14:37:55 -0700
Local: Fri, Jun 22 2012 5:37 pm
Subject: Re: Testing question

You need to populate the matchdict manually.  Add this to your code:

req.matchdict['templateid'] = 1

Pyramid doesn't actually route the URL, so the matchdict isn't populated.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe Dallago  
View profile  
 More options Jun 22 2012, 5:39 pm
From: Joe Dallago <jd.dall...@gmail.com>
Date: Fri, 22 Jun 2012 14:39:08 -0700
Local: Fri, Jun 22 2012 5:39 pm
Subject: Re: Testing question

Just out of curiosity, why is the _id getting passed into your view as an
argument?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Toni Mueller  
View profile  
 More options Jun 22 2012, 6:43 pm
From: Toni Mueller <d...@tonimueller.org>
Date: Sat, 23 Jun 2012 00:43:11 +0200
Local: Fri, Jun 22 2012 6:43 pm
Subject: Re: Testing question

Hi,

On Fri, Jun 22, 2012 at 02:37:55PM -0700, Joe Dallago wrote:
> req.matchdict['templateid'] = 1

ummm... yes, but I thought that it should be created automatically.

> Pyramid doesn't actually route the URL, so the matchdict isn't populated.

Ok, but I didn't find this in the docs. Will have to dig through them
again.

To answer your other question:

That's an artifact after some refactoring. Thanks for pointing it
out to me - it will be deleted.

Kind regards,
--Toni++


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joe Dallago  
View profile  
 More options Jun 22 2012, 6:54 pm
From: Joe Dallago <jd.dall...@gmail.com>
Date: Fri, 22 Jun 2012 15:54:43 -0700
Local: Fri, Jun 22 2012 6:54 pm
Subject: Re: Testing question

> ummm... yes, but I thought that it should be created automatically.

It isn't, someone asked this in IRC the other day, and I just gave you the
answer that was given by the leaders of the community.  A discussion about
the difference between a "unit" test and a "functional" test ensued. You
can read it here<http://irclogs.rulim.de/%23pyramid/%23pyramid.2012-06-20.log.html#t20...>.
 If you don't like that solution, miranon later chimes in and gives a
possible workaround
here<http://irclogs.rulim.de/%23pyramid/%23pyramid.2012-06-21.log.html#t20...>.
 I'm not exactly sure where it is in the docs, please link to it if you
find it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »