Fix oauth_dispatch tests BOM-732

This commit is contained in:
Jeremy Bowman
2019-09-18 17:02:38 -04:00
parent f08a2ed88d
commit 10d9bb22b5
2 changed files with 8 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ from datetime import datetime
import six
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django_mysql.models import ListCharField
from oauth2_provider.settings import oauth2_settings
@@ -19,6 +20,7 @@ from openedx.core.djangolib.markup import HTML
from openedx.core.lib.request_utils import get_request_or_stub
@python_2_unicode_compatible
class RestrictedApplication(models.Model):
"""
This model lists which django-oauth-toolkit Applications are considered 'restricted'
@@ -35,7 +37,7 @@ class RestrictedApplication(models.Model):
class Meta:
app_label = 'oauth_dispatch'
def __unicode__(self):
def __str__(self):
"""
Return a unicode representation of this object
"""
@@ -59,6 +61,7 @@ class RestrictedApplication(models.Model):
return access_token.expires == datetime(1970, 1, 1, tzinfo=utc)
@python_2_unicode_compatible
class ApplicationAccess(models.Model):
"""
Specifies access control information for the associated Application.
@@ -81,7 +84,7 @@ class ApplicationAccess(models.Model):
def get_scopes(cls, application):
return cls.objects.get(application=application).scopes
def __unicode__(self):
def __str__(self):
"""
Return a unicode representation of this object.
"""
@@ -91,6 +94,7 @@ class ApplicationAccess(models.Model):
)
@python_2_unicode_compatible
class ApplicationOrganization(models.Model):
"""
Associates a DOT Application to an Organization.
@@ -129,7 +133,7 @@ class ApplicationOrganization(models.Model):
queryset = queryset.filter(relation_type=relation_type)
return [r.organization.name for r in queryset]
def __unicode__(self):
def __str__(self):
"""
Return a unicode representation of this object.
"""

View File

@@ -63,7 +63,7 @@ class AccessTokenLoginMixin(object):
return self.client.post(
self.login_with_access_token_url,
HTTP_AUTHORIZATION=b"Bearer {0}".format(access_token if access_token else self.access_token)
HTTP_AUTHORIZATION=u"Bearer {0}".format(access_token if access_token else self.access_token).encode('utf-8')
)
def _assert_access_token_is_valid(self, access_token=None):