/appengine_django/auth/tests.py

http://google-app-engine-django.googlecode.com/ · Python · 58 lines · 43 code · 2 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. BASIC_TESTS = """
  15. >>> from google.appengine.api import users
  16. >>> from models import User, AnonymousUser
  17. >>> appengine_user = users.User("test@example.com")
  18. >>> django_user = User.get_djangouser_for_user(appengine_user)
  19. >>> django_user.email == appengine_user.email()
  20. True
  21. >>> django_user.username == appengine_user.nickname()
  22. True
  23. >>> django_user.user == appengine_user
  24. True
  25. >>> django_user.username = 'test2'
  26. >>> key = django_user.save()
  27. >>> django_user.username == 'test2'
  28. True
  29. >>> django_user2 = User.get_djangouser_for_user(appengine_user)
  30. >>> django_user2 == django_user
  31. True
  32. >>> django_user.is_authenticated()
  33. True
  34. >>> django_user.is_staff
  35. False
  36. >>> django_user.is_active
  37. True
  38. >>> a = AnonymousUser()
  39. >>> a.is_authenticated()
  40. False
  41. >>> a.is_staff
  42. False
  43. >>> a.is_active
  44. False
  45. >>> a.groups.all()
  46. []
  47. >>> a.user_permissions.all()
  48. []
  49. """
  50. __test__ = {'BASIC_TESTS': BASIC_TESTS}