PageRenderTime 26ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/appengine_django/auth/tests.py

http://google-app-engine-django.googlecode.com/
Python | 58 lines | 44 code | 1 blank | 13 comment | 0 complexity | 1c93820c99f45ef3f2cd98438ca1086e MD5 | raw file
 1# Copyright 2008 Google Inc.
 2#
 3# Licensed under the Apache License, Version 2.0 (the "License");
 4# you may not use this file except in compliance with the License.
 5# You may obtain a copy of the License at
 6#
 7#     http://www.apache.org/licenses/LICENSE-2.0
 8#
 9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15BASIC_TESTS = """
16>>> from google.appengine.api import users
17>>> from models import User, AnonymousUser
18>>> appengine_user = users.User("test@example.com")
19>>> django_user = User.get_djangouser_for_user(appengine_user)
20>>> django_user.email == appengine_user.email()
21True
22>>> django_user.username == appengine_user.nickname()
23True
24>>> django_user.user == appengine_user
25True
26
27>>> django_user.username = 'test2'
28>>> key = django_user.save()
29>>> django_user.username == 'test2'
30True
31
32>>> django_user2 = User.get_djangouser_for_user(appengine_user)
33>>> django_user2 == django_user
34True
35
36>>> django_user.is_authenticated()
37True
38>>> django_user.is_staff
39False
40>>> django_user.is_active
41True
42
43>>> a = AnonymousUser()
44>>> a.is_authenticated()
45False
46>>> a.is_staff
47False
48>>> a.is_active
49False
50>>> a.groups.all()
51[]
52>>> a.user_permissions.all()
53[]
54
55
56"""
57
58__test__ = {'BASIC_TESTS': BASIC_TESTS}