Skip to content

Commit

Permalink
Merge pull request #20 from texastribune/django-17
Browse files Browse the repository at this point in the history
Bump tox to test latest Django 1.7
  • Loading branch information
crccheck committed Jul 11, 2014
2 parents 75f3111 + ba6a44a commit f347dd4
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test:
#
# -s don't capture stdout
#
python $(MANAGE) test -s
python -W ignore::RuntimeWarning $(MANAGE) test django_object_actions -s


resetdb:
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Getting started *(with virtualenvwrapper)*::
cd django-object-actions
# set up your virtualenv
mkvirtualenv django-object-actions
pip install -r requirements-dev.txt
pip install -r requirements.txt
export DJANGO_SETTINGS_MODULE=example_project.settings
add2virtualenv .
make test # run test suite
Expand Down
14 changes: 14 additions & 0 deletions django_object_actions/factories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.contrib.auth import get_user_model

import factory


class UserFactory(factory.DjangoModelFactory):
FACTORY_FOR = get_user_model()
first_name = factory.Sequence(lambda i: u'John{0}'.format(i))
last_name = factory.Sequence(lambda i: u'Doe{0}'.format(i))
username = factory.LazyAttribute(lambda x: '{0}{1}'.format(
x.first_name, x.last_name))
email = factory.LazyAttribute(lambda x: '{0}@{1}.com'.format(
x.first_name.lower(), x.last_name.lower()))
password = factory.PostGenerationMethodCall('set_password', 'password')
3 changes: 3 additions & 0 deletions django_object_actions/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# HACK to get factoryboy logging to shut up
import logging
logging.getLogger("factory").setLevel(logging.WARN)
6 changes: 4 additions & 2 deletions django_object_actions/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ def test_get_djoa_button_attrs_custom_attrs_get_partitioned(self):


class QuerySetIshTest(TestCase):
fixtures = ['sample_data']

def setUp(self):
# as defined in initial_data fixture
# WISHLIST don't depend on fixture
self.obj = Poll.objects.get(pk=1)

Expand Down Expand Up @@ -102,8 +103,9 @@ def test_queryset_supports_update(self):


class DecoratorTest(TestCase):
fixtures = ['sample_data']

def setUp(self):
# as defined in initial_data fixture
# WISHLIST don't depend on fixture
self.obj = Poll.objects.get(pk=1)
self.queryset = Poll.objects.all()
Expand Down
7 changes: 6 additions & 1 deletion django_object_actions/tests/tests.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from django.test import TestCase

from example_project.polls.models import Choice
from ..factories import UserFactory


class LoggedInTestCase(TestCase):
def setUp(self):
super(LoggedInTestCase, self).setUp()
self.client.login(username='admin', password='admin')
UserFactory.create(is_staff=True, is_superuser=True,
username='admin', password='admin')
self.assertTrue(self.client.login(username='admin', password='admin'))


class AppTests(LoggedInTestCase):
fixtures = ['sample_data']

def test_bare_mixin_works(self):
# hit admin that doesn't have any tools defined, just the mixin
response = self.client.get('/admin/polls/poll/add/')
Expand Down
46 changes: 0 additions & 46 deletions example_project/polls/fixtures/initial_data.json

This file was deleted.

28 changes: 28 additions & 0 deletions example_project/polls/fixtures/sample_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[
{
"pk": 1,
"model": "polls.poll",
"fields": {
"pub_date": "2012-10-20T18:20:35Z",
"question": "Do you like me?"
}
},
{
"pk": 1,
"model": "polls.choice",
"fields": {
"choice_text": "Yes",
"poll": 1,
"votes": 0
}
},
{
"pk": 2,
"model": "polls.choice",
"fields": {
"choice_text": "No",
"poll": 1,
"votes": 100
}
}
]
27 changes: 17 additions & 10 deletions example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ def project_dir(*paths):
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'


# Make this unique, and don't share it with anybody.
SECRET_KEY = 'lolimasekrit'

ROOT_URLCONF = 'example_project.urls'


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


INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -71,3 +71,10 @@ def project_dir(*paths):
)

TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'


# STFU, Django 1.7
# To be deleted once Django 1.8 testing begins
SILENCED_SYSTEM_CHECKS = [
'1_7.W001',
]
9 changes: 0 additions & 9 deletions requirements-dev.txt

This file was deleted.

6 changes: 6 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,9 @@ Django>=1.4.2

dj-database-url>=0.2.1
psycopg2>=2.4.5

Werkzeug>=0.8.3
django-extensions>=0.9
django-nose
tox==1.7.1
factory-boy==2.4.1
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
url="https://github.com/texastribune/django-object-actions",
packages=[
'django_object_actions',
# The following packages are only here to support testing.
'django_object_actions.tests',
'example_project',
],
include_package_data=True, # automatically include things from MANIFEST
license='Apache License, Version 2.0',
Expand Down
11 changes: 7 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ envlist =
py33django17,
py34django16,
py34django17,

downloadcache = {toxworkdir}/.cache
skipsdist = True

[testenv]
setenv =
PYTHONPATH = {toxinidir}
commands = {envpython} example_project/manage.py test django_object_actions
deps =
dj_database_url
django-extensions>=0.9
django-nose
factory-boy==2.4.1

[testenv:py26django14]
basepython=python2.6
Expand Down Expand Up @@ -65,13 +68,13 @@ deps =
basepython=python2.7
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/
https://www.djangoproject.com/download/1.7c1/tarball/

[testenv:py33django17]
basepython=python3.3
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/
https://www.djangoproject.com/download/1.7c1/tarball/

[testenv:py34django16]
basepython=python3.4
Expand All @@ -83,4 +86,4 @@ deps =
basepython=python3.4
deps =
{[testenv]deps}
https://www.djangoproject.com/download/1.7b3/tarball/
https://www.djangoproject.com/download/1.7c1/tarball/

0 comments on commit f347dd4

Please sign in to comment.