188a9d801d1fd501147f787f1ea56ad7bb2a05cc
[openstack-build/django_openstack_auth-build.git] / centos7 / rpm / SOURCES / 0008-Extend-User-from-AbstractBaseUser-and-AnonymousUser.patch
1 From 3b8ac9e333033c9500a88a826f32c64d264f6641 Mon Sep 17 00:00:00 2001
2 From: Matthias Runge <mrunge@redhat.com>
3 Date: Thu, 26 Mar 2015 14:04:18 +0100
4 Subject: [PATCH] Extend User from AbstractBaseUser and AnonymousUser
5
6 Django-1.8 added _meta classes for User models,
7 which aren't supported by AnonymousUsers, the
8 AbstractBaseUser provides default implementation
9 for _meta classes.
10
11 SimpleTest has been deprecated since Django-1.6 and
12 was now removed.
13
14 Unfortunately, this change drops Django-1.6 (and earlier) compatibility.
15
16 Co-Authored-By: Lin Hua Cheng <os.lcheng@gmail.com>
17
18 Partially Implements: blueprint django18
19 Change-Id: Ie243fd2304421694023f579f49f8fa201e761ba3
20
21 (cherry picked from commit da2395146eb0cc351f1ee46848a142433629d53a)
22 ---
23  openstack_auth/tests/run_tests.py |  7 +++++--
24  openstack_auth/user.py            |  7 +++++--
25  tox.ini                           | 19 ++++++++++++++-----
26  3 files changed, 24 insertions(+), 9 deletions(-)
27
28 diff --git a/openstack_auth/tests/run_tests.py b/openstack_auth/tests/run_tests.py
29 index 32ec848..b317967 100644
30 --- a/openstack_auth/tests/run_tests.py
31 +++ b/openstack_auth/tests/run_tests.py
32 @@ -20,7 +20,10 @@ import sys
33  os.environ['DJANGO_SETTINGS_MODULE'] = 'openstack_auth.tests.settings'
34  
35  import django
36 -from django.test import simple as test_simple
37 +if django.VERSION < (1, 8, 0):
38 +    from django.test.simple import DjangoTestSuiteRunner as test_runner
39 +else:
40 +    from django.test.runner import DiscoverRunner as test_runner
41  
42  if hasattr(django, 'setup'):
43      django.setup()
44 @@ -35,7 +38,7 @@ def run(*test_args):
45          "..",
46      )
47      sys.path.insert(0, parent)
48 -    failures = test_simple.DjangoTestSuiteRunner().run_tests(test_args)
49 +    failures = test_runner().run_tests(test_args)
50      sys.exit(failures)
51  
52  
53 diff --git a/openstack_auth/user.py b/openstack_auth/user.py
54 index 77325de..9310aa7 100644
55 --- a/openstack_auth/user.py
56 +++ b/openstack_auth/user.py
57 @@ -119,7 +119,7 @@ class Token(object):
58          self.serviceCatalog = auth_ref.service_catalog.get_data()
59  
60  
61 -class User(models.AnonymousUser):
62 +class User(models.AbstractBaseUser, models.AnonymousUser):
63      """A User class with some extra special sauce for Keystone.
64  
65      In addition to the standard Django user attributes, this class also has
66 @@ -193,7 +193,7 @@ class User(models.AnonymousUser):
67                   services_region=None, user_domain_id=None,
68                   user_domain_name=None, domain_id=None, domain_name=None,
69                   project_id=None, project_name=None,
70 -                 is_federated=False, unscoped_token=None):
71 +                 is_federated=False, unscoped_token=None, password=None):
72          self.id = id
73          self.pk = id
74          self.token = token
75 @@ -223,6 +223,9 @@ class User(models.AnonymousUser):
76          self.tenant_id = self.project_id
77          self.tenant_name = self.project_name
78  
79 +        # Required by AbstractBaseUser
80 +        self.password = None
81 +
82      def __unicode__(self):
83          return self.username
84  
85 diff --git a/tox.ini b/tox.ini
86 index 3b78a4e..2745e72 100644
87 --- a/tox.ini
88 +++ b/tox.ini
89 @@ -1,7 +1,7 @@
90  [tox]
91  minversion = 1.6
92  skipsdist = True
93 -envlist = py27,py27dj14,py27dj15,pep8,py33,py34
94 +envlist = py27,py27dj17,py27dj18,pep8,py33,py34
95  
96  [testenv]
97  usedevelop = True
98 @@ -16,18 +16,27 @@ deps = -r{toxinidir}/requirements.txt
99         -r{toxinidir}/test-requirements.txt
100  commands = python openstack_auth/tests/run_tests.py {posargs}
101  
102 -[testenv:py27dj15]
103 -commands = pip install django>=1.5,<1.6
104 +[testenv:cover]
105 +setenv = DJANGO_SETTINGS_MODULE=openstack_auth.tests.settings
106 +commands =
107 +    python -m coverage erase
108 +    python -m coverage run openstack_auth/tests/run_tests.py  {posargs}
109 +    python -m coverage html --include='openstack_auth/*' --omit='openstack_auth/tests/*' -d 'reports'
110 +    python -m coverage xml --include='openstack_auth/*' --omit='openstack_auth/tests/*'
111 +
112 +[testenv:py27dj17]
113 +commands = pip install django>=1.7,<1.8
114             python openstack_auth/tests/run_tests.py {posargs}
115  
116 -[testenv:py27dj14]
117 -commands = pip install django>=1.4,<1.5
118 +[testenv:py27dj18]
119 +commands = pip install django>=1.8,<1.9
120             python openstack_auth/tests/run_tests.py {posargs}
121  
122  [testenv:pep8]
123  setenv = DJANGO_SETTINGS_MODULE=openstack_auth.tests.settings
124  commands = flake8
125  
126 +
127  [testenv:venv]
128  commands = {posargs}
129