Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2013-05-23 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
---+-
 Reporter:  egmanoj@…  |Owner:  nobody
 Type:  Bug|   Status:  closed
Component:  Testing framework  |  Version:  1.1-beta
 Severity:  Normal |   Resolution:  duplicate
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+-
Changes (by deni):

 * status:  new => closed
 * resolution:   => duplicate


Comment:

 This is a duplice of [https://code.djangoproject.com/ticket/10899].

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/075.46292333f186ed06ee2863d83b1e05e9%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2013-05-22 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
---+
 Reporter:  egmanoj@…  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Testing framework  |  Version:  1.1-beta
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+

Comment (by EmilStenstrom):

 If I'm understanding this bug correctly, it asks for a way to create
 session data (which is essentially server-based) from the client side.
 This workflow becomes really strange, and as @hongshuning suggests, the
 best way to simulate this is to do requests just like a normal web server
 does.

 I suggest this bug is WONTFIX:ed.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/075.0937034108d211cda1460ab9071c0c7e%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2012-12-30 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
---+--
 Reporter:  egmanoj@…  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Testing framework  |  Version:  1.1-beta-1
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--

Comment (by hongshuning):

 I think kragen is right. The web server will not create any session object
 unless a client try to visit a web page. In the origin test case's setUp()
 method, the client does not visit any web page, so no session object
 created by django. At that time, {{{self.client.session["key"]}}} is
 nonsense. So, if you want to use the session object, you must visit a web
 page at first, just like a login access or any others.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2012-10-28 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
---+--
 Reporter:  egmanoj@…  |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Testing framework  |  Version:  1.1-beta-1
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+--
Changes (by kitsunde):

 * cc: kitsunde@… (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2011-05-16 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
--+---
   Reporter:  egmanoj@…   |  Owner:  nobody
   Type:  Bug | Status:  new
  Milestone:  |  Component:  Testing framework
Version:  1.1-beta-1  |   Severity:  Normal
 Resolution:  |   Keywords:
   Triage Stage:  Accepted|  Has patch:  0
Needs documentation:  0   |Needs tests:  0
Patch needs improvement:  0   |  Easy pickings:  0
--+---

Comment (by prestontimmons):

 Crosslinking to #10899 which would fix this issue. Also #15740, which is
 strictly the bug fix portion of #10899.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2011-05-16 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
--+---
   Reporter:  egmanoj@…   |  Owner:  nobody
   Type:  Bug | Status:  new
  Milestone:  |  Component:  Testing framework
Version:  1.1-beta-1  |   Severity:  Normal
 Resolution:  |   Keywords:
   Triage Stage:  Accepted|  Has patch:  0
Needs documentation:  0   |Needs tests:  0
Patch needs improvement:  0   |  Easy pickings:  0
--+---
Changes (by bmihelac):

 * cc: bmihelac@… (added)
 * easy:   => 0


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2011-01-31 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
-+--
   Reporter:  egmanoj@…  | Owner:  nobody
 Status:  new| Milestone:
  Component:  Testing framework  |   Version:  1.1-beta-1
 Resolution: |  Keywords:
   Triage Stage:  Accepted   | Has patch:  0 
Needs documentation:  0  |   Needs tests:  0 
Patch needs improvement:  0  |  
-+--
Changes (by nodet):

 * cc: nodet (added)


-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2010-02-02 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Accepted   | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by russellm):

  * stage:  Unreviewed => Accepted

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

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



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-23 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by Manoj Govindan ):

 Replying to [comment:8 simonredfern]:
 > I just came across the same problem. Feels like a Bug with a capital B
 to me. Can't get the workaround to work either.


 I created a dummy, non-staff user and logged him in inside my `setUp()`.
 Not clean or ideal, but works for me as I don't have any code based on
 user identity (yet). I don't know your scenario but this might be worth a
 try.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-23 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by simonredfern):

 I just came across the same problem. Feels like a Bug with a capital B to
 me. Can't get the workaround to work either.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-20 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by Manoj Govindan ):

 Replying to [comment:6 kra...@canonical.org]:
 > Manoj: let's say that you have some view at `/blort` that will store
 something into the session. Then I think you can do this (although I
 haven't tested this code):
 >

 [snip]

 >
 > Does that work for you?
 >
 [[BR]]
 I tested the code. It works like you said: *if* I call a view that saves
 something to the session from within my `setUp`.

 That said, it does not solve my original problem. I don't want to call a
 view in the `setUp` method for this purpose alone.

 [[BR]]
 >
 > So now I know. It's not a bug, really; it's just that Django-under-test
 behaves in a way that makes it error-prone to write unit tests for.
 >
 [[BR]]
 I think it *is* a bug in that the client is not simulating "real world"
 behavior.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-20 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by kra...@canonical.org):

 Manoj: let's say that you have some view at `/blort` that will store
 something into the session. Then I think you can do this (although I
 haven't tested this code):

 {{{
 class MyTestCase(TestCase):
 def setUp(self):
 # self.client = Client() (not necessary in modern Django)
 self.client.get('/blort') # after this, self.client.session is a
 real session
 s = self.client.session
 s['key'] = 'value'
 s.save()
 }}}

 Does that work for you?

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-20 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by Manoj Govidnan ):

 >
 >  5. But you can't just say `self.client.session['foo'] = 'bar';
 self.client.session.save()` because, as explained in my previous two
 comments, you get a separate session object for each time you say
 `self.client.session`. Instead you have to say `s = self.client.session;
 s['foo'] = 'bar'; s.save()`, and then everything will work.
 >
 [[BR]]
 Can you please point where these changes should be made in the context of
 the sample test case given above? I tested after making the changes you
 suggested inside the `setUp()` method as well as the `test_foo()` method
 and it still did not work.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-19 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by kra...@canonical.org):

 Aha! Now I understand.

  1. Until you've gotten back a cookie from the middleware (which *does*
 run from `Client.get`) you don't have the session object. Instead you get
 the stupid useless empty dict.
  2. Obviously you don't get a cookie until after you make a request.
 (Unless you call `Client.login`.)
  3. But even if you make a request, Django won't set the cookie unless the
 view tries to store something in `request.session`.
  4. At that point `self.client.session` will give you a useful object, but
 it's not the same object the view will use, so if you want to communicate
 with the view, you have to call `.save()` on it.
  5. But you can't just say `self.client.session['foo'] = 'bar';
 self.client.session.save()` because, as explained in my previous two
 comments, you get a separate session object for each time you say
 `self.client.session`. Instead you have to say `s = self.client.session;
 s['foo'] = 'bar'; s.save()`, and then everything will work.

 So now I know. It's not a bug, really; it's just that Django-under-test
 behaves in a way that makes it error-prone to write unit tests for.

 It might still be useful to factor out the code in `Client.login` that
 creates a session and saves the session cookie without making an HTTP
 request, for tests that want to set up test session data without having to
 go through whatever series of views are necessary for a real person to set
 that data.

 Maybe this is some kind of a Django FAQ.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-18 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by kra...@canonical.org):

 ...also, making `Client.session` a lazy property would
 [http://www.dougblog.com/articles/2008/jan/23/test-client-session/ solve a
 funny little interface bug] with authenticated sessions in tests. (Is that
 one logged in Trac yet?)

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-18 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Comment (by kra...@canonical.org):

 I'm just now running into the same thing.  The simple fix, of just having
 `Client._session` return `engine.SessionStore(None)` in the case where the
 cookie isn't set, generates a new session (with a new session ID) every
 time you refer to `self.client.session`, so we probably need to make
 `session` a lazy attribute if we want `Client` to be useful for testing
 storage of data for anonymous sessions; but I think also we have to
 somehow get the cookie set properly; there's code to do that down in the
 middle of `Client.login` which could be factored out, and of course that's
 already very much duplicative with `SessionMiddleware.process_response`,
 which is the code path that normally runs to set the browser cookie for
 the session; so we could factor that out from two places and use it in a
 third. (But I guess it doesn't run in `Client.get`. Does `Client.get`
 bypass middleware?)

 I don't know my way around the code very well, so it's possible that the
 anonymous user above and I are doing something dumb.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---



Re: [Django] #11475: test.Client.session.save() raises error for anonymous users

2009-07-14 Thread Django
#11475: test.Client.session.save() raises error for anonymous users
+---
  Reporter:  egma...@gmail.com  | Owner:  nobody
Status:  new| Milestone:
 Component:  Testing framework  |   Version:  1.1-beta-1
Resolution: |  Keywords:
 Stage:  Unreviewed | Has_patch:  0 
Needs_docs:  0  |   Needs_tests:  0 
Needs_better_patch:  0  |  
+---
Changes (by anonymous):

 * cc: egma...@gmail.com (added)
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~--~~~~--~~--~--~---