Skip to content

Commit

Permalink
Got rudimentary tests for the cookbook working. (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanHayes committed Jan 20, 2016
1 parent c18d839 commit 3c882eb
Show file tree
Hide file tree
Showing 14 changed files with 347 additions and 45 deletions.
4 changes: 4 additions & 0 deletions docs/code/authentication.py
@@ -0,0 +1,4 @@
import mock


OAuth20Authentication = mock.Mock()
10 changes: 10 additions & 0 deletions docs/code/manage.py
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file added docs/code/myapp/__init__.py
Empty file.
Empty file added docs/code/myapp/api/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions docs/code/myapp/api/resources.py
@@ -0,0 +1,8 @@
from tastypie.resources import ModelResource

from ..models import User


class UserResource(ModelResource):
class Meta:
object_class = User.objects.all()
8 changes: 8 additions & 0 deletions docs/code/myapp/models.py
@@ -0,0 +1,8 @@
import mock

from django.contrib.auth.models import User # flake8: noqa


Choice = mock.MagicMock()
Poll = mock.MagicMock()
MyModel = mock.MagicMock()
4 changes: 4 additions & 0 deletions docs/code/myapp/urls.py
@@ -0,0 +1,4 @@
from tastypie.api import Api


my_api = Api()
Empty file added docs/code/myproject/__init__.py
Empty file.
85 changes: 85 additions & 0 deletions docs/code/myproject/settings.py
@@ -0,0 +1,85 @@
"""
Django settings for myproject project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '%ovvje%lh&k-%0v!@_c1gygt#aq-!o3*t$(hpee7@aj&35cr3a'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'myapp',
'tastypie',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'myproject.urls'

WSGI_APPLICATION = 'myproject.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'
10 changes: 10 additions & 0 deletions docs/code/myproject/urls.py
@@ -0,0 +1,10 @@
from django.conf.urls import patterns, include, url
from django.contrib import admin

urlpatterns = patterns('',
# Examples:
# url(r'^$', 'myproject.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),
)
14 changes: 14 additions & 0 deletions docs/code/myproject/wsgi.py
@@ -0,0 +1,14 @@
"""
WSGI config for myproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.wsgi import get_wsgi_application # flake8: noqa
application = get_wsgi_application()
4 changes: 4 additions & 0 deletions docs/conf.py
Expand Up @@ -18,12 +18,16 @@
# sys.path.append(os.path.abspath('.'))

import datetime
import os
import sys

sys.path.append('..')

from tastypie import __short_version__, __version__ # flake8: noqa

docs_path = os.path.dirname(__file__)
doctest_path = [os.path.join(docs_path, 'code'), os.path.join(docs_path, '..')]

# -- General configuration ----------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down

0 comments on commit 3c882eb

Please sign in to comment.