mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Tests: limit live API integration tests in Travis runs
To conserve our ESP test accounts' send quotas, don't run the live API integration tests 13 times in every Travis run. Instead, just run them twice, on a representative set of Python/Django combinations: * Once on Python 2.7 (currently with Django 1.8) * Once on Python 3.x (currently 3.5 with Django 1.9) (Prep for running weekly tests on Travis cron.) The *non*-integration tests still run on all combos. * Introduce RUN_LIVE_TESTS environment var to control whether live API integration test cases should run. Default True, except in Travis-CI runs default False. * Enable RUN_LIVE_TESTS in .travis.yml matrix for the Python/Django combos listed above.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Anymail test utils
|
||||
import sys
|
||||
from distutils.util import strtobool
|
||||
|
||||
import os
|
||||
import re
|
||||
@@ -10,6 +11,25 @@ from contextlib import contextmanager
|
||||
from django.test import Client
|
||||
|
||||
|
||||
def envbool(var, default=False):
|
||||
"""Returns value of environment variable var as a bool, or default if not set.
|
||||
|
||||
Converts `'true'` to `True`, and `'false'` to `False`.
|
||||
See :func:`~distutils.util.strtobool` for full list of allowable values.
|
||||
"""
|
||||
val = os.getenv(var, None)
|
||||
if val is None:
|
||||
return default
|
||||
else:
|
||||
return strtobool(val)
|
||||
|
||||
|
||||
# RUN_LIVE_TESTS: whether to run live API integration tests.
|
||||
# True by default, except in CONTINUOUS_INTEGRATION job.
|
||||
# (See comments and overrides in .travis.yml.)
|
||||
RUN_LIVE_TESTS = envbool('RUN_LIVE_TESTS', default=not envbool('CONTINUOUS_INTEGRATION'))
|
||||
|
||||
|
||||
def decode_att(att):
|
||||
"""Returns the original data from base64-encoded attachment content"""
|
||||
return b64decode(att.encode('ascii'))
|
||||
|
||||
Reference in New Issue
Block a user