diff --git a/.travis.yml b/.travis.yml index ec7edf9..17c2cc1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,23 +8,16 @@ cache: directories: - $HOME/.cache/pip env: - - DJANGO=django==1.7.11 - - DJANGO=django==1.7.11 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres" - - DJANGO=django==1.7.11 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" - - DJANGO=django==1.8.12 - - DJANGO=django==1.8.12 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres" - - DJANGO=django==1.8.12 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" - - DJANGO=django==1.9.5 - - DJANGO=django==1.9.5 DB_ENGINE="django.db.backends.postgresql" DB_NAME="test_project" DB_USER="postgres" - - DJANGO=django==1.9.5 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" + - DJANGO=django==1.8.14 + - DJANGO=django==1.8.14 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres" + - DJANGO=django==1.8.14 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" + - DJANGO=django==1.9.9 + - DJANGO=django==1.9.9 DB_ENGINE="django.db.backends.postgresql" DB_NAME="test_project" DB_USER="postgres" + - DJANGO=django==1.9.9 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" + - DJANGO=django==1.10 + - DJANGO=django==1.10 DB_ENGINE="django.db.backends.postgresql" DB_NAME="test_project" DB_USER="postgres" + - DJANGO=django==1.10 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" matrix: - exclude: - - python: 3.5 - env: DJANGO=django==1.7.11 - - python: 3.5 - env: DJANGO=django==1.7.11 DB_ENGINE="django.db.backends.postgresql_psycopg2" DB_NAME="test_project" DB_USER="postgres" - - python: 3.5 - env: DJANGO=django==1.7.11 DB_ENGINE="django.db.backends.mysql" DB_NAME="test_project" DB_USER="travis" fast_finish: true services: - postgresql diff --git a/src/tests/runtests.py b/src/tests/runtests.py index 51c5afd..de8ab0e 100755 --- a/src/tests/runtests.py +++ b/src/tests/runtests.py @@ -72,7 +72,7 @@ def main(): DATABASES={ "default": database_setting }, - ROOT_URLCONF="urls", + ROOT_URLCONF='test_watson.urls', INSTALLED_APPS=( "django.contrib.auth", "django.contrib.contenttypes", @@ -93,6 +93,12 @@ def main(): USE_TZ=True, STATIC_URL="/static/", TEST_RUNNER="django.test.runner.DiscoverRunner", + TEMPLATES=[{ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': ['templates'], + 'APP_DIRS': True, + }], + ) # Run Django setup (1.7+). import django diff --git a/src/tests/test_watson/tests.py b/src/tests/test_watson/tests.py index 5618852..54085d6 100644 --- a/src/tests/test_watson/tests.py +++ b/src/tests/test_watson/tests.py @@ -29,7 +29,6 @@ from watson.backends import escape_query from test_watson.models import WatsonTestModel1, WatsonTestModel2 from test_watson import admin # Force early registration of all admin models. - class RegistrationTest(TestCase): def testRegistration(self): @@ -560,9 +559,7 @@ class ComplexRegistrationTest(SearchTestBase): class AdminIntegrationTest(SearchTestBase): - - urls = "test_watson.urls" - + def setUp(self): super(AdminIntegrationTest, self).setUp() self.user = User( @@ -601,9 +598,6 @@ class AdminIntegrationTest(SearchTestBase): class SiteSearchTest(SearchTestBase): - - urls = "test_watson.urls" - def testSiteSearch(self): # Test a search than should find everything. response = self.client.get("/simple/?q=title") diff --git a/src/tests/test_watson/urls.py b/src/tests/test_watson/urls.py index 3985be0..42b01c0 100644 --- a/src/tests/test_watson/urls.py +++ b/src/tests/test_watson/urls.py @@ -1,8 +1,8 @@ -from django.conf.urls import patterns, url, include +from django.conf.urls import url, include from django.contrib import admin -urlpatterns = patterns("", +urlpatterns = [ url("^simple/", include("watson.urls")), @@ -17,5 +17,4 @@ urlpatterns = patterns("", }), url("^admin/", include(admin.site.urls)), - -) +] diff --git a/src/tests/urls.py b/src/tests/urls.py index 604f3cd..408e7bc 100644 --- a/src/tests/urls.py +++ b/src/tests/urls.py @@ -4,7 +4,4 @@ should be added within the test folders, and use TestCase.urls to set them. This helps the tests remain isolated. """ -from django.conf.urls import patterns - - -urlpatterns = patterns("") +urlpatterns = [] diff --git a/src/watson/management/commands/buildwatson.py b/src/watson/management/commands/buildwatson.py index e6e06a4..de257c1 100644 --- a/src/watson/management/commands/buildwatson.py +++ b/src/watson/management/commands/buildwatson.py @@ -58,28 +58,35 @@ class Command(BaseCommand): args = "[[--engine=search_engine] ... ]" help = "Rebuilds the database indices needed by django-watson. You can (re-)build index for selected models by specifying them" - option_list = BaseCommand.option_list + ( - make_option("--engine", - help="Search engine models are registered with"), + def add_arguments(self, parser): + parser.add_argument("apps", nargs="*", action="store", default=[]) + parser.add_argument('--engine', + action="store", + help='Search engine models are registered with' ) - + @transaction.atomic() def handle(self, *args, **options): """Runs the management command.""" activate(settings.LANGUAGE_CODE) verbosity = int(options.get("verbosity", 1)) - + # see if we're asked to use a specific search engine - if options['engine']: + if options.get('engine'): engine_slug = options['engine'] engine_selected = True else: engine_slug = "default" engine_selected = False - + + # work-around for legacy optparser hack in BaseCommand. In Django=1.10 the + # args are collected in options['apps'], but in earlier versions they are + # kept in args. + if len(options['apps']): + args = options['apps'] + # get the search engine we'll be checking registered models for, may be "default" search_engine = get_engine(engine_slug) - models = [] for model_name in args: try: diff --git a/src/watson/urls.py b/src/watson/urls.py index 5644227..de2355f 100644 --- a/src/watson/urls.py +++ b/src/watson/urls.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals -from django.conf.urls import url, patterns +from django.conf.urls import url from watson.views import search, search_json