Update tests
This commit is contained in:
parent
b21fc0d733
commit
6aeed3951a
3 changed files with 5 additions and 36 deletions
|
@ -4,9 +4,6 @@ machine:
|
|||
node:
|
||||
version: 5.10.1
|
||||
environment:
|
||||
DEBUG: true
|
||||
DATABASE_URL: sqlite://~/database.db
|
||||
EMAIL_BACKEND: django.core.mail.backends.console.EmailBackend
|
||||
BUILD_PRODUCTION: true
|
||||
|
||||
dependencies:
|
||||
|
@ -14,6 +11,7 @@ dependencies:
|
|||
- ./build
|
||||
cache_directories:
|
||||
- env
|
||||
- node_modules
|
||||
|
||||
test:
|
||||
override:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
coverage==4.0.3
|
||||
colorama==0.3.6
|
||||
flake8==2.5.0
|
||||
markdown==2.6.6
|
||||
|
|
36
runtests
36
runtests
|
@ -1,17 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
import coverage
|
||||
import os, sys
|
||||
import subprocess
|
||||
from colorama import Fore, init
|
||||
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
|
||||
from django.core.management import execute_from_command_line
|
||||
init(autoreset=True)
|
||||
|
||||
|
||||
bin_dir = os.path.abspath(os.path.join(sys.executable, os.path.pardir))
|
||||
PERCENTAGE = 95
|
||||
EXIT_CODE = 0
|
||||
|
||||
|
||||
|
@ -20,34 +16,15 @@ def check_if_exit_code():
|
|||
print("\n{}Tests Failed. {}Please check messages above and then re-run the command.".format(Fore.RED, Fore.YELLOW))
|
||||
exit(EXIT_CODE)
|
||||
|
||||
|
||||
cov = coverage.Coverage(
|
||||
source=["project"],
|
||||
omit=["*/wsgi.py", "*/settings.py", "*/migrations/*.py", "*/__init__*", "*/tests.py"]
|
||||
)
|
||||
cov.start()
|
||||
|
||||
print(Fore.YELLOW + "Running Tests...")
|
||||
execute_from_command_line([sys.argv[0], 'test'])
|
||||
cov.stop()
|
||||
|
||||
print("{}Tests Complete. {}Collecting Coverage...".format(Fore.GREEN, Fore.YELLOW))
|
||||
cov.save()
|
||||
cov.html_report()
|
||||
covered = cov.report()
|
||||
if covered < PERCENTAGE:
|
||||
print("{}ERROR: Your coverage needs to be higher. Current coverage: {}%. Required: {}%.".format(Fore.RED, covered, PERCENTAGE))
|
||||
EXIT_CODE = 1
|
||||
|
||||
check_if_exit_code()
|
||||
print("{}Coverage Complete. {}Linting...".format(Fore.GREEN, Fore.YELLOW))
|
||||
print("{}Linting...".format(Fore.YELLOW))
|
||||
|
||||
|
||||
FLAKE8_IGNORE = '--ignore=E128,E501,E401,E402'
|
||||
try:
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'project', FLAKE8_IGNORE, '--exclude=migrations,settings,wsgi.py,__init__.py'])
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'theme', FLAKE8_IGNORE])
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'scripts', FLAKE8_IGNORE])
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), sys.argv[0], FLAKE8_IGNORE])
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), 'pelicanconf.py', FLAKE8_IGNORE])
|
||||
subprocess.check_output([os.path.join(bin_dir, 'flake8'), sys.argv[0], FLAKE8_IGNORE]) # Test this file
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(Fore.RED, e.output.decode())
|
||||
EXIT_CODE = 1
|
||||
|
@ -59,9 +36,4 @@ print("{}All Python tests passed! {}Testing Static Files...".format(Fore.GREEN,
|
|||
EXIT_CODE = os.system('npm test')
|
||||
check_if_exit_code()
|
||||
|
||||
print("{}All static tests passed! {}Running spell check...".format(Fore.GREEN, Fore.YELLOW))
|
||||
|
||||
EXIT_CODE = os.system('')
|
||||
check_if_exit_code()
|
||||
|
||||
print("{}All Tests Passed!".format(Fore.GREEN))
|
||||
|
|
Reference in a new issue