fixes bug 1132723 - Drop test-utils

This commit is contained in:
Peter Bengtsson 2015-10-15 10:49:38 -07:00
Родитель 2e27e98cb9
Коммит aaaf897b7a
6 изменённых файлов: 48 добавлений и 22 удалений

Просмотреть файл

@ -538,10 +538,21 @@ Another common mistake is to *not* have `SESSION_COOKIE_SECURE = False` in your
`airmozilla/settings/local.py` but using `http://localhost:8000` to reach `airmozilla/settings/local.py` but using `http://localhost:8000` to reach
the site. the site.
### Tests are not working ### Tests are slow
By default when you run `./manage.py test ...` it will re-create the
database for every run. This takes 5-10 seconds extra time every time.
If you know that the testing process doesn't involve any complexities
in terms of migrations, you can speed up the tests a lot by setting
the environment variable `REUSE_DB=1`. For example like this:
REUSE_DB=1 ./manage.py test
Or to make it stick, use:
export REUSE_DB=1
./manage.py test
If tests don't work around code you didn't touch, it might be that your test
database is out-of-sync so then next time simply run: `FORCE_DB=1 ./manage.py test`.
Migrations Migrations
---------- ----------

Просмотреть файл

@ -1,6 +1,9 @@
from .base import * import sys
import os
from .base import * # NOQA
try: try:
from .local import * from .local import * # NOQA
except ImportError, exc: # pragma: no cover except ImportError, exc: # pragma: no cover
exc.args = tuple([ exc.args = tuple([
'%s (did you rename airmozilla/settings/local.py-dist?)' % ( '%s (did you rename airmozilla/settings/local.py-dist?)' % (
@ -10,7 +13,8 @@ except ImportError, exc: # pragma: no cover
raise exc raise exc
# This takes care of removing # This takes care of removing that pesky warning, about raven not
# being configured in local development, that looks like an error.
try: try:
assert RAVEN_CONFIG['dsn'] assert RAVEN_CONFIG['dsn']
except (NameError, KeyError, AssertionError): # pragma: no cover except (NameError, KeyError, AssertionError): # pragma: no cover
@ -18,3 +22,14 @@ except (NameError, KeyError, AssertionError): # pragma: no cover
INSTALLED_APPS = list(INSTALLED_APPS) INSTALLED_APPS = list(INSTALLED_APPS)
INSTALLED_APPS.remove('raven.contrib.django.raven_compat') INSTALLED_APPS.remove('raven.contrib.django.raven_compat')
INSTALLED_APPS = tuple(INSTALLED_APPS) INSTALLED_APPS = tuple(INSTALLED_APPS)
if sys.argv[1] == 'test':
from .test import * # NOQA
# Are you getting full benefit from django-nose?
if not os.getenv('REUSE_DB', 'false').lower() in ('true', '1', ''):
print (
"Note!\n\tIf you want much faster tests in local development "
"consider setting the REUSE_DB=1 environment variable.\n"
)

Просмотреть файл

@ -55,6 +55,8 @@ INSTALLED_APPS = (
'django_nose', # deliberately making this the last one 'django_nose', # deliberately making this the last one
) )
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
# Necessary so that test-utils doesn't try to execute some deprecated # Necessary so that test-utils doesn't try to execute some deprecated
# functionality on the database connection. # functionality on the database connection.
SQL_RESET_SEQUENCES = False SQL_RESET_SEQUENCES = False
@ -292,7 +294,7 @@ try:
# ujson is a much faster json serializer # ujson is a much faster json serializer
# We tell the django-jsonview decorator to use it only if the ujson # We tell the django-jsonview decorator to use it only if the ujson
# package is installed and can be imported # package is installed and can be imported
import ujson import ujson # NOQA
JSON_MODULE = 'ujson' JSON_MODULE = 'ujson'
JSON_USE_DJANGO_SERIALIZER = False JSON_USE_DJANGO_SERIALIZER = False
except ImportError: except ImportError:

Просмотреть файл

@ -1,4 +1,8 @@
# These settings will always be overriding for all test runs """
These settings will always be overriding for all test runs.
"""
import tempfile
EMAIL_FROM_ADDRESS = 'doesnt@matter.com' EMAIL_FROM_ADDRESS = 'doesnt@matter.com'
@ -13,12 +17,12 @@ MOZILLIANS_API_KEY = 'supersecret'
VIDLY_API_URL = 'http://vid.ly.shouldneveractuallybeused.com/api/' VIDLY_API_URL = 'http://vid.ly.shouldneveractuallybeused.com/api/'
# So that we never accidentally send tweets during tests # So that we never accidentally send tweets during tests
TWITTER_CONSUMER_KEY = \
TWITTER_CONSUMER_SECRET = \
TWITTER_ACCESS_TOKEN = \
TWITTER_ACCESS_TOKEN_SECRET = "test" TWITTER_ACCESS_TOKEN_SECRET = "test"
TWEETER_BACKEND = None TWITTER_CONSUMER_KEY = TWITTER_ACCESS_TOKEN_SECRET
TWITTER_CONSUMER_SECRET = TWITTER_CONSUMER_KEY
TWITTER_ACCESS_TOKEN = TWITTER_CONSUMER_KEY
TWEETER_BACKEND = None
URL_TRANSFORM_PASSWORDS = { URL_TRANSFORM_PASSWORDS = {
'bla': 'bla', 'bla': 'bla',
@ -34,7 +38,6 @@ SENTRY_DSN = None
SITE_URL = 'http://localhost:8000' SITE_URL = 'http://localhost:8000'
AWS_ACCESS_KEY_ID = AWS_SECRET_ACCESS_KEY = 'something' AWS_ACCESS_KEY_ID = AWS_SECRET_ACCESS_KEY = 'something'
#S3_UPLOAD_BUCKET = 'air-mozilla-uploads'
EDGECAST_SECURE_KEY = 'soemthing' EDGECAST_SECURE_KEY = 'soemthing'
@ -42,7 +45,6 @@ AKAMAI_SECURE_KEY = 'something'
BROWSERID_AUDIENCES = ['http://testserver'] BROWSERID_AUDIENCES = ['http://testserver']
import tempfile
MEDIA_ROOT = tempfile.mkdtemp(prefix='testmedia') MEDIA_ROOT = tempfile.mkdtemp(prefix='testmedia')
SCRAPE_CREDENTIALS = {} SCRAPE_CREDENTIALS = {}
@ -78,7 +80,7 @@ BROWSERID_DISABLED = False
# Don't actually use celery in tests # Don't actually use celery in tests
CELERY_ALWAYS_EAGER = True CELERY_ALWAYS_EAGER = True
SCREENCAPTURES_NO_PICTURES = 5 # faster SCREENCAPTURES_NO_PICTURES = 5 # faster
# Deliberately disabled since reducing the size of PNGs # Deliberately disabled since reducing the size of PNGs
# slows down the tests significantly and we have deliberate # slows down the tests significantly and we have deliberate

Просмотреть файл

@ -10,8 +10,6 @@ web:
- "8000:8000" - "8000:8000"
environment: environment:
- DISPLAY=:99.0 - DISPLAY=:99.0
# If you want to reset your test db uncomment this
# - FORCE_DB=1
links: links:
- db - db
- memcached - memcached

Просмотреть файл

@ -96,13 +96,11 @@ bleach==1.4.1
jingo==0.7.1 jingo==0.7.1
# sha256: BrZLrybHpDbLuBRk56UAR66jDbEFnb5uCdxEPvojuiA # sha256: BrZLrybHpDbLuBRk56UAR66jDbEFnb5uCdxEPvojuiA
django-appconf==0.6 django-appconf==0.6
# sha256: Ik3Rv9j8259nJWxUMBR7TAEF1y9qyM47ymtIZEnsYGI # sha256: c2rlPj7EfbuzBJmZwYzlRYWvKZ74gXLZony1_aKdqgA
# sha256: 6gWLBd1MYed3X8xk-j2j7kMPcT3gMsO7WvOpC_UbLro # sha256: gPnTaQ4NuDDDdq6XFygUjXYN1k1ETRwJJ0fWY6DXL3M
django-nose==1.4.1 django-nose==1.4.2
# sha256: RORjnsBXprap3duGnU46SBj8knjsSQzOOa7whEBZKpM # sha256: RORjnsBXprap3duGnU46SBj8knjsSQzOOa7whEBZKpM
django-session-csrf==0.5 django-session-csrf==0.5
# sha256: ih29HHrehSBq53DJzl9DCBoJjJX5lK8RP2Q06QBVmmc
https://github.com/jbalogh/test-utils/archive/e42e031.zip#egg=test-utils
# sha256: sGqGRRqZ1sJr-mUIKZnb9ljgh-WW6SkszmiLU-q6qto # sha256: sGqGRRqZ1sJr-mUIKZnb9ljgh-WW6SkszmiLU-q6qto
django-sha2==0.4 django-sha2==0.4
# sha256: TEiNy4TP_Yi80rFlGWK3Z_m7JFIGQHyOpngEPNOdPKg # sha256: TEiNy4TP_Yi80rFlGWK3Z_m7JFIGQHyOpngEPNOdPKg