diff --git a/discover_jenkins/tasks/run_sloccount.py b/discover_jenkins/tasks/run_sloccount.py index 280029f..f5441fd 100755 --- a/discover_jenkins/tasks/run_sloccount.py +++ b/discover_jenkins/tasks/run_sloccount.py @@ -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", diff --git a/tests/manage.py b/tests/manage.py new file mode 100644 index 0000000..0fc36a3 --- /dev/null +++ b/tests/manage.py @@ -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) diff --git a/tests/requirements.pip b/tests/requirements.pip new file mode 100644 index 0000000..b5c4253 --- /dev/null +++ b/tests/requirements.pip @@ -0,0 +1,8 @@ +django>=1.5 +pylint>=0.23 +coverage>=3.4 +pyflakes +pep8>=1.3 +lettuce +selenium +flake8 diff --git a/tests/test_project/__init__.py b/tests/test_project/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_project/fixtures/default_users.json b/tests/test_project/fixtures/default_users.json new file mode 100644 index 0000000..550c25a --- /dev/null +++ b/tests/test_project/fixtures/default_users.json @@ -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" + } + } +] diff --git a/tests/test_project/settings.py b/tests/test_project/settings.py new file mode 100644 index 0000000..fc7d90a --- /dev/null +++ b/tests/test_project/settings.py @@ -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, + }, + } +} \ No newline at end of file diff --git a/tests/test_project/static/js/test.js b/tests/test_project/static/js/test.js new file mode 100644 index 0000000..34914f0 --- /dev/null +++ b/tests/test_project/static/js/test.js @@ -0,0 +1,7 @@ +function toggle() { + "use strict"; + var unused, x = true; + if (x && y) { + x = false; + } +} diff --git a/tests/test_project/test_app/__init__.py b/tests/test_project/test_app/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_project/test_app/migrations/0001_initial.py b/tests/test_project/test_app/migrations/0001_initial.py new file mode 100644 index 0000000..92da11b --- /dev/null +++ b/tests/test_project/test_app/migrations/0001_initial.py @@ -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 diff --git a/tests/test_project/test_app/migrations/__init__.py b/tests/test_project/test_app/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_project/test_app/static/js/test.js b/tests/test_project/test_app/static/js/test.js new file mode 100644 index 0000000..a993ef5 --- /dev/null +++ b/tests/test_project/test_app/static/js/test.js @@ -0,0 +1,8 @@ +/*jshint unused:true */ + +function toggle() { + var unused, x = true; + if (x) { + x = false; + } +} diff --git a/tests/test_project/test_app/templates/404.html b/tests/test_project/test_app/templates/404.html new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_project/test_app/templates/500.html b/tests/test_project/test_app/templates/500.html new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_project/test_app/templates/test_app/wm_test_click.html b/tests/test_project/test_app/templates/test_app/wm_test_click.html new file mode 100644 index 0000000..066415f --- /dev/null +++ b/tests/test_project/test_app/templates/test_app/wm_test_click.html @@ -0,0 +1,14 @@ + + +
+