the controllers and template is pretty straight forward.  when i visit
it on a browser via paster serve, it displays properly when given a
valid id in the db.  as for the exception during nosetests, it is the
same one u would get when you provide an invalid id at GET /contacts/
[invalid_id].  this confuses me b/c the print statement in my test
case validates that the row is in the test database.  however, when
you hit self.app.get(' /contacts/[contact_id]'), the exception it
throws indicate that the id is invalid, hence contact is None, and
hence 'None has no member named "full_name"'.

anyway, here are my controllers and template:

controllers/contacts.py - get_one()
@expose("addressbook.templates.contacts.get_one")
    def get_one(self, contact_id):
        """
        Gets an existing contact.

        GET /contacts/[contact_id]
        """
        contact = DBSession.query(Contact).get(contact_id)
        return dict(contact=contact)

templates/contacts/get_one.html (the stuff inside the body tag)

<h2>${contact.full_name}</h2>

<dl>
  <dt>Name:</dt>
  <dd>${contact.given_name} ${contact.family_name}</dd>

  <dt>Birthday:</dt>
  <dd>${contact.birthday}</dd>
</dl>


On Nov 30, 3:51 am, "Diez B. Roggisch" <[email protected]> wrote:
> steve schrieb:
>
>
>
> > hi,
>
> > i am trying to do the following:
>
> > class TestGetOneContactsController(TestController):
> >     def test_get_one(self):
> >         contact = DBSession.query(Contact).first()
> >         print contact.id
> >         print contact.full_name
> >         print contact.given_name
> >         print contact.family_name
> >         response = self.app.get("/contacts/%s" % contact.id)
> >         msg = contact.given_name
> >         assert_true(msg in response)
>
> > the print statements prints out the data properly.  but once it hits
> > the response statement, the test is failing b/c genshi is having
> > difficulties evaluating full_name: 'UndefinedError: None has no member
> > named "full_name"'.
>
> > please let me know what going on.  i have been struggling with testing
> > in turbogears.
>
> Without seeing the /contacts/-controller and the template, there isn't
> much we can say.
>
> Diez

--

You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.


Reply via email to