straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

Simulate user login in tests #176

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm trying to write some functional unit tests using the django client.  My
layout view requires a user to login to reach that page.  How would I go
about simulating a login?  Thanks.  

import unittest
from django.test.client import Client
from myapp.models import Layout
from google.appengine.ext import db
import os

class TestAdmin(unittest.TestCase):
  def setUp(self):
    self.client = Client()

  def testPage(self):
    response = self.client.get('/app/layout')
#This fails because i'm returned a status_code of 301
    self.failUnlessEqual(200, response.status_code)

Original issue reported on code.google.com by akume...@gmail.com on 2 Jul 2009 at 8:13

GoogleCodeExporter commented 9 years ago
There's client.login():
http://docs.djangoproject.com/en/dev/topics/testing/#topics-testing
Please don't use the issue tracking system to post about bugs in your code. 
This is not 
a helpdesk. Please use the discussion group, instead.

Original comment by wkornew...@gmail.com on 3 Jul 2009 at 9:14

GoogleCodeExporter commented 9 years ago
sorry about the post.  keep up the good work.  app-engine-patch rocks.  

Original comment by akume...@gmail.com on 3 Jul 2009 at 9:26