From a6443ada8555621c5088332c2a3f114da12e95f5 Mon Sep 17 00:00:00 2001 From: Jose Soares Date: Wed, 22 Apr 2015 10:34:30 -0400 Subject: [PATCH] [-] 1.6/1.7/1.8 compatiable changes (WIP) --- .travis.yml | 5 +++-- categories/fixtures/categories.json | 16 ++++++++++++++++ categories/templatetags/category_tags.py | 6 +++--- categories/tests/__init__.py | 2 -- categories/tests/test_category_import.py | 5 +++-- categories/tests/test_manager.py | 6 ++++-- 6 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 categories/fixtures/categories.json diff --git a/.travis.yml b/.travis.yml index 58b13b7..6f4eaee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ python: - "2.6" - "2.7" env: - - DJANGO_VERSION=1.3.1 - - DJANGO_VERSION=1.4 + - DJANGO_VERSION=1.6.11 + - DJANGO_VERSION=1.7.7 + - DJANGO_VERSION=1.8 install: - pip install Django==$DJANGO_VERSION - pip install -e . diff --git a/categories/fixtures/categories.json b/categories/fixtures/categories.json new file mode 100644 index 0000000..43d0f3d --- /dev/null +++ b/categories/fixtures/categories.json @@ -0,0 +1,16 @@ +[ + { + "fields": { + "level": 0, + "lft": 1, + "name": "Category 1", + "order": 1, + "parent": null, + "rght": 10, + "slug": "category-1", + "tree_id": 1 + }, + "model": "categories.category", + "pk": 1 + } +] diff --git a/categories/templatetags/category_tags.py b/categories/templatetags/category_tags.py index b594e61..f21a42a 100644 --- a/categories/templatetags/category_tags.py +++ b/categories/templatetags/category_tags.py @@ -1,7 +1,7 @@ from django import template from django.db.models import get_model -from django.template import (Node, TemplateSyntaxError, VariableDoesNotExist, - FilterExpression) +from django.template import (Node, TemplateSyntaxError, VariableDoesNotExist) +from django.template.base import FilterExpression from categories.base import CategoryBase from categories.models import Category from mptt.utils import drilldown_tree_for_node @@ -186,7 +186,7 @@ def display_drilldown_as_ul(category, using='categories.Category'): cat = get_category(category, using) if cat is None: return {'category': cat, 'path': []} - else: + else: return {'category': cat, 'path': drilldown_tree_for_node(cat)} diff --git a/categories/tests/__init__.py b/categories/tests/__init__.py index 42800ce..e69de29 100644 --- a/categories/tests/__init__.py +++ b/categories/tests/__init__.py @@ -1,2 +0,0 @@ - -__fixtures__ = ['categories.json'] diff --git a/categories/tests/test_category_import.py b/categories/tests/test_category_import.py index 6923747..fd83864 100644 --- a/categories/tests/test_category_import.py +++ b/categories/tests/test_category_import.py @@ -1,14 +1,15 @@ # test spaces in hierarchy # test tabs in hierarchy # test mixed -import unittest import os + +from django.test import TestCase from categories.models import Category from categories.management.commands.import_categories import Command from django.core.management.base import CommandError -class CategoryImportTest(unittest.TestCase): +class CategoryImportTest(TestCase): def setUp(self): pass diff --git a/categories/tests/test_manager.py b/categories/tests/test_manager.py index 2d46a93..b2fb6c6 100644 --- a/categories/tests/test_manager.py +++ b/categories/tests/test_manager.py @@ -1,9 +1,11 @@ # test active returns only active items -import unittest +from django.test import TestCase from categories.models import Category -class CategoryManagerTest(unittest.TestCase): +class CategoryManagerTest(TestCase): + fixtures = ['categories.json'] + def setUp(self): pass