diff --git a/categories/__init__.py b/categories/__init__.py index f040a4f..4d6fedb 100644 --- a/categories/__init__.py +++ b/categories/__init__.py @@ -1,7 +1,7 @@ __version_info__ = { 'major': 0, 'minor': 5, - 'micro': 0, + 'micro': 1, 'releaselevel': 'final', 'serial': 0 } diff --git a/categories/fixtures/test_category_spaces.txt b/categories/fixtures/test_category_spaces.txt index 87bb4d6..025edbe 100644 --- a/categories/fixtures/test_category_spaces.txt +++ b/categories/fixtures/test_category_spaces.txt @@ -4,6 +4,5 @@ Category 1 Category 2 Category 2-1 Category 2-1-1 - Category 2-2 Category 3 Category 3-1 \ No newline at end of file diff --git a/categories/fixtures/test_category_tabs.txt b/categories/fixtures/test_category_tabs.txt index e75f796..207a634 100644 --- a/categories/fixtures/test_category_tabs.txt +++ b/categories/fixtures/test_category_tabs.txt @@ -4,6 +4,5 @@ Category 1 Category 2 Category 2-1 Category 2-1-1 - Category 2-2 Category 3 Category 3-1 \ No newline at end of file diff --git a/categories/management/commands/import_categories.py b/categories/management/commands/import_categories.py index 9bddd55..f06f597 100644 --- a/categories/management/commands/import_categories.py +++ b/categories/management/commands/import_categories.py @@ -48,7 +48,6 @@ class Command(BaseCommand): current_parents = {0: None} for line in lines: - print line if len(line) == 0: continue if line[0] == ' ' or line[0] == '\t': @@ -58,12 +57,9 @@ class Command(BaseCommand): raise CommandError("You can't mix spaces and tabs for indents") level = line.count(indent) current_parents[level] = self.make_category(line, parent=current_parents[level-1]) - print current_parents else: # We are back to a zero level, so reset the whole thing current_parents = {0: self.make_category(line)} - print current_parents - print Category.objects.all() def handle(self, *file_paths, **options): """ diff --git a/categories/tests/__init__.py b/categories/tests/__init__.py index 68846cb..6934d61 100644 --- a/categories/tests/__init__.py +++ b/categories/tests/__init__.py @@ -1,4 +1,4 @@ -from categories.tests import views +from categories.tests.category_import import * from categories.tests.templatetags import * __fixtures__ = ['categories.json'] diff --git a/categories/tests/category_import.py b/categories/tests/category_import.py index ead1514..94801ce 100644 --- a/categories/tests/category_import.py +++ b/categories/tests/category_import.py @@ -4,6 +4,7 @@ import unittest, os from categories.models import Category from categories.management.commands.import_categories import Command +from django.core.management.base import CommandError class CategoryImportTest(unittest.TestCase): def setUp(self): @@ -28,10 +29,12 @@ class CategoryImportTest(unittest.TestCase): def testImportSpaceDelimited(self): + Category.objects.all().delete() self._import_file('test_category_spaces.txt') def testImportTabDelimited(self): + Category.objects.all().delete() self._import_file('test_category_tabs.txt') @@ -39,11 +42,11 @@ class CategoryImportTest(unittest.TestCase): """ Should raise an exception. """ - string1 = "cat1\n cat1-1\n\tcat1-2-FAIL!\n" - string2 = "cat1\n\tcat1-1\n cat1-2-FAIL!\n" + string1 = ["cat1"," cat1-1", "\tcat1-2-FAIL!",""] + string2 = ["cat1","\tcat1-1"," cat1-2-FAIL!",""] cmd = Command() # raise Exception - self.assertRaises(cmd.parse_lines(string1), Command.CommandError) - self.assertRaises(cmd.parse_lines(string2), Command.CommandError) + self.assertRaises(CommandError, cmd.parse_lines, string1) + self.assertRaises(CommandError, cmd.parse_lines, string2) \ No newline at end of file diff --git a/categories/tests/templatetags.py b/categories/tests/templatetags.py index c48ce52..5568119 100644 --- a/categories/tests/templatetags.py +++ b/categories/tests/templatetags.py @@ -36,13 +36,7 @@ class GetCategoryTest(TestCase): """ Test that we can properly retrieve a category. """ - rock_resp = u'Rock\rRock > Surf rock\rRock > Southern rock\rRock > Soft rock\rRock > Rock and roll\rRock > Rap rock\rRock > Punk rock\rRock > Psychedelic rock\rRock > Progressive rock\rRock > Power pop\rRock > Paisley Underground\rRock > New Wave\rRock > J-Rock\rRock > Heavy metal\rRock > Hard rock\rRock > Glam rock\rRock > Garage rock\rRock > Folk rock\rRock > Desert rock\rRock > Dark cabaret\rRock > C-Rock\rRock > Blues-rock\rRock > Alternative rock\r' - resp = self.render_template('{% load category_tags %}{% get_category "/Rock" as cat_list %}{% for cat in cat_list %}{{ cat }}\r{% endfor %}') + rock_resp = u'\n' + resp = self.render_template('{% load category_tags %}{% display_path_as_ul "/Rock" %}') self.assertEqual(resp, rock_resp) - - crock_resp = u'Rock\rRock > C-Rock\r' - resp = self.render_template('{% load category_tags %}{% get_category "/Rock/C-Rock" as cat_list %}{% for cat in cat_list %}{{ cat }}\r{% endfor %}') - self.assertEqual(resp, crock_resp) - - resp = self.render_template('{% load category_tags %}{% get_category %}') \ No newline at end of file