Re: testing views problem

2011-04-14 Thread Daniel Gerzo

On 14.4.2011 20:12, Daniel Gerzo wrote:

On 14.4.2011 18:21, Shawn Milochik wrote:

If the code sample you pasted is accurate, then you have an extra
space between 'activate' and the next forward-slash.


I doesn't really matter what kind of URL I pass to get() method (I am
actually using reverse mostly), the thing is that I am getting
HttpResponse instead of Response and I don't really understand why.



Just a followup to myself, for anyone who might experience this issue.
I couldn't come up to a reason why I was not getting the right 
attributes filled in and I did many searches, been looking through the 
code etc, and in the end I have came across this post 
http://stackoverflow.com/questions/1932706/django-test-clients-context-is-empty-from-the-shell.


Basically the issue is that the Django test code monkeypatches the 
template rendering and that's where these values get their content. 
Unfrotunately, running this code from the shell doesn't work as I was 
expecting (am quite new to testing and all this stuff, so I wanted to 
play around first in the shell to know what to expect.)


Carl Meyer noted that he has a patch to fix this, but is not quite ready 
yet.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: testing views problem

2011-04-14 Thread Daniel Gerzo

On 14.4.2011 18:21, Shawn Milochik wrote:

If the code sample you pasted is accurate, then you have an extra
space between 'activate' and the next forward-slash.


I doesn't really matter what kind of URL I pass to get() method (I am 
actually using reverse mostly), the thing is that I am getting 
HttpResponse instead of Response and I don't really understand why.


--
Kind regards
  Daniel Gerzo

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: testing views problem

2011-04-14 Thread Shawn Milochik
If the code sample you pasted is accurate, then you have an extra
space between 'activate' and the next forward-slash.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Testing Views

2007-06-21 Thread [EMAIL PROTECTED]

the dict was supposed to be passing in the logged user, though I am
starting to think I don't need to pass anything as long as I can get
the session set.
Another developer in the office wrote the auth code so it took me a
bit to get a handle on just what it was doing.

I am thinking if i get the session set properly I will be ok...


On Jun 21, 12:44 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 6/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > Jeremy,
> >Thanks for the response.
>
> > to be more clear maybe -
> >i was actually trying to pass the dictionary as part of the request
> > object - since the view looks for the logged participant in the
> > request from the page.
>
> > what if my view does not take a qstring?  I need to pass it some
> > pieces in the request...
>
> I'm not sure I follow.  There are 4 ways to pass information in the
> request: the URL itself, the querystring, the POST variables, and
> cookies.
>
> How were you wanting to "pass in some pieces in the request"?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Views

2007-06-21 Thread Jeremy Dunck

On 6/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Jeremy,
>Thanks for the response.
>
> to be more clear maybe -
>i was actually trying to pass the dictionary as part of the request
> object - since the view looks for the logged participant in the
> request from the page.
>
> what if my view does not take a qstring?  I need to pass it some
> pieces in the request...

I'm not sure I follow.  There are 4 ways to pass information in the
request: the URL itself, the querystring, the POST variables, and
cookies.

How were you wanting to "pass in some pieces in the request"?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Views

2007-06-21 Thread [EMAIL PROTECTED]

Jeremy,
   Thanks for the response.

to be more clear maybe -
   i was actually trying to pass the dictionary as part of the request
object - since the view looks for the logged participant in the
request from the page.

what if my view does not take a qstring?  I need to pass it some
pieces in the request...

I will also try setting a real session variable..

thanks again, I will let you know if it works..

On Jun 21, 12:18 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote:
> On 6/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> ...
>
> > response = self.client.get('/broadcasts/new/',
> > {'loggedParticipant': participant} )
>
> It's not clear to me what the dictionary there is meant to do.  That
> dictionary is passed as the querystring, *not* as the session.
>
> Also, if you have django.contrib.sessions in your INSTALLED_APPS (and
> you should if you're using Django sessions), then it appears that
> client.session re-constructs a SessionWrapper each call, based on
> .cookies[settings.SESSION_COOKIE_NAME].
>
> As such, you'll want to save a real session object (see
> Session.objects.save()), and then set a cookie with the session_key of
> that saved object.
>
> You could, of course, make that part of a fixture used by the test case.
>
> I haven't done this myself, so would be interested if it works out for you.
>
> Cheers,
>   Jeremy


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Testing Views

2007-06-21 Thread Jeremy Dunck

On 6/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
...
> response = self.client.get('/broadcasts/new/',
> {'loggedParticipant': participant} )

It's not clear to me what the dictionary there is meant to do.  That
dictionary is passed as the querystring, *not* as the session.

Also, if you have django.contrib.sessions in your INSTALLED_APPS (and
you should if you're using Django sessions), then it appears that
client.session re-constructs a SessionWrapper each call, based on
.cookies[settings.SESSION_COOKIE_NAME].

As such, you'll want to save a real session object (see
Session.objects.save()), and then set a cookie with the session_key of
that saved object.

You could, of course, make that part of a fixture used by the test case.

I haven't done this myself, so would be interested if it works out for you.

Cheers,
  Jeremy

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---