Add a skeleton for the tests

This commit is contained in:
Brandon Konkle 2013-08-07 23:45:41 -05:00
parent 28fc26086b
commit cf296a8ccc
17 changed files with 172 additions and 1 deletions

View file

@ -6,7 +6,7 @@ from optparse import make_option
from discover_jenkins.utils import check_output, get_app_locations
class SloccountTask(object):
class SlocCountTask(object):
option_list = (
make_option(
"--sloccount-with-migrations",

10
tests/manage.py Normal file
View file

@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_project.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

8
tests/requirements.pip Normal file
View file

@ -0,0 +1,8 @@
django>=1.5
pylint>=0.23
coverage>=3.4
pyflakes
pep8>=1.3
lettuce
selenium
flake8

View file

View file

@ -0,0 +1,22 @@
[
{
"pk": 1,
"model": "auth.user",
"fields": {
"username": "admin",
"first_name": "System",
"last_name": "Administrator",
"is_active": true,
"is_superuser": true,
"is_staff": true,
"last_login": "2010-05-07 15:39:46",
"groups": [
1
],
"user_permissions": [],
"password": "sha1$21c1d$f88ae4ad970f09a92786216f2bf9817f235c22e3",
"email": "admin@admin.com",
"date_joined": "2010-05-06 17:39:56"
}
}
]

View file

@ -0,0 +1,61 @@
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ROOT_URLCONF = 'test_app.urls'
SECRET_KEY = 'nokey'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEST_PROJECT_APPS = (
'discover_jenkins',
'test_project.test_app',
)
INSTALLED_APPS = (
'django.contrib.contenttypes',
) + TEST_PROJECT_APPS
DATABASE_ENGINE = 'sqlite3'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.%s' % DATABASE_ENGINE,
}
}
TEST_RUNNER = 'discover_jenkins.runner.DiscoverCIRunner'
TEST_TASKS = (
'discover_jenkins.tasks.with_coverage.CoverageTask',
'discover_jenkins.tasks.run_pylint.PyLintTask',
'discover_jenkins.tasks.run_jshint.JSHintTask',
'discover_jenkins.tasks.run_sloccount.SlocCountTask',
)
JSHINT_CHECKED_FILES = [os.path.join(BASE_DIR, 'project/static/js/test.js')]
STATIC_URL = '/static/'
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
},
},
'loggers': {
'django.request': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': True,
},
}
}

View file

@ -0,0 +1,7 @@
function toggle() {
"use strict";
var unused, x = true;
if (x && y) {
x = false;
}
}

View file

View file

@ -0,0 +1,9 @@
from south.v2 import SchemaMigration
class Migration(SchemaMigration):
def forwards(self, orm):
a = 1 # pyflakes/pylint violation
pass
def backwards(self, orm):
pass

View file

@ -0,0 +1,8 @@
/*jshint unused:true */
function toggle() {
var unused, x = true;
if (x) {
x = false;
}
}

View file

@ -0,0 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Windmill testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<div>
<h1>Windmill testing</h1>
<button id="wm_click" onclick="document.getElementById('wm_target').innerHTML = 'Button clicked'">Click me</button>
<div id="wm_target"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,6 @@
from django.conf.urls import patterns, url
urlpatterns = patterns('',
url(r'^test_click/$', 'django.views.generic.simple.direct_to_template',
{'template': 'test_app/wm_test_click.html'}, name='wm_test_click')
)

0
tests/tests/__init__.py Normal file
View file

26
tests/tests/test_utils.py Normal file
View file

@ -0,0 +1,26 @@
import os
from datetime import timedelta
from django.test import TestCase
import discover_jenkins
import test_project
class TestUtils(TestCase):
def test_total_seconds(self):
"""
The total_seconds util should show that 5 minutes is 300 seconds.
"""
delta = timedelta(minutes=5)
self.assertEqual(discover_jenkins.utils.total_seconds(delta), 300)
def test_app_locations(self):
"""
The app locations should come from the test_project settings.
"""
locations = [os.path.dirname(discover_jenkins.__file__),
os.path.dirname(test_project.test_app.__file__)]
self.assertEqual(discover_jenkins.utils.get_app_locations(),
locations)