Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Commit

Permalink
Fix Django ORM Tests for Django 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Prin committed Dec 3, 2015
1 parent b5a6cae commit e2751cb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tests/test_django_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@

# Mock a Django environment
from django.conf import global_settings
global_settings.SECRET_KEY = 'NotASecret'
os.environ['DJANGO_SETTINGS_MODULE'] = 'django_settings'
sys.modules['django_settings'] = django_settings = imp.new_module(
'django_settings')
django_settings.SECRET_KEY = 'xyzzy'
from django.db import models

os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_django_settings'
from django.conf import settings
settings.SECRET_KEY = 'this string is not a real Django SECRET_KEY'
settings.INSTALLED_APPS = ['tests.test_django_orm']

import django
django.setup()
from django.apps import AppConfig


class DjangoOrmTestApp(AppConfig):
""" App Config for Django Helper"""
name = 'oauth2client.tests.test_django_orm'
verbose_name = "Google OAuth2 Django Helper"


from django.db import models
from oauth2client._helpers import _from_bytes
from oauth2client.client import Credentials
from oauth2client.client import Flow
Expand All @@ -49,7 +60,6 @@


class TestCredentialsField(unittest.TestCase):

def setUp(self):
self.fake_model = FakeCredentialsModel()
self.fake_model_field = self.fake_model._meta.get_field('credentials')
Expand Down Expand Up @@ -85,7 +95,6 @@ def test_field_value_to_string_none(self):


class TestFlowField(unittest.TestCase):

class FakeFlowModel(models.Model):
flow = FlowField()

Expand Down Expand Up @@ -120,7 +129,6 @@ def test_field_value_to_string_none(self):


class TestStorage(unittest.TestCase):

def setUp(self):
access_token = 'foo'
client_id = 'some_client_id'
Expand Down
34 changes: 34 additions & 0 deletions tests/test_django_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os

SECRET_KEY = 'this string is not a real django secret key'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join('.', 'db.sqlite3'),
}
}
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware'
)

ALLOWED_HOSTS = ['testserver']

GOOGLE_OAUTH2_CLIENT_ID = 'client_id2'
GOOGLE_OAUTH2_CLIENT_SECRET = 'hunter2'
GOOGLE_OAUTH2_SCOPES = ('https://www.googleapis.com/auth/cloud-platform',)

ROOT_URLCONF = 'tests.test_django_util'

0 comments on commit e2751cb

Please sign in to comment.