From 74d9910a4c3ea506dd199d049276d187dcf39ab8 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:13:04 -0500 Subject: [PATCH 1/7] Got rid of the debugging print statements --- categories/management/commands/import_categories.py | 4 ---- 1 file changed, 4 deletions(-) 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): """ From 6aad1c44cc45519e107e57c6465144d0c3f3878f Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:13:34 -0500 Subject: [PATCH 2/7] Changed the import to import from category_import --- categories/tests/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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'] From 31f1bfef8dce51065dcc07d9894964a972de743e Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:14:50 -0500 Subject: [PATCH 3/7] Checking for raising the correct exception and moved the strings used in the test to a list of strings --- categories/tests/category_import.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/categories/tests/category_import.py b/categories/tests/category_import.py index ead1514..c752fbd 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): @@ -39,11 +40,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 From 2bfe7534280ef3b4c47f13f4f82410867e5bd726 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:15:21 -0500 Subject: [PATCH 4/7] Need to delete all the objects before each test because the import checks its work. --- categories/tests/category_import.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/categories/tests/category_import.py b/categories/tests/category_import.py index c752fbd..94801ce 100644 --- a/categories/tests/category_import.py +++ b/categories/tests/category_import.py @@ -29,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') From 89646a6ceee4361966c9a61c632affe8ee7d14a2 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:16:07 -0500 Subject: [PATCH 5/7] The test for importing checks the first child. With two children either could be 1st, so remove one. --- categories/fixtures/test_category_spaces.txt | 1 - categories/fixtures/test_category_tabs.txt | 1 - 2 files changed, 2 deletions(-) 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 From efc4b9339a4c2f2b8f59ffb20e2d01b69304be0f Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:17:41 -0500 Subject: [PATCH 6/7] Updated the test to test a new template tag, not the old one. --- categories/tests/templatetags.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 From f142f1a77c375a51778db90fdeb3b6e98ae48c07 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Mon, 14 Feb 2011 11:19:41 -0500 Subject: [PATCH 7/7] Bumped version number to 0.5.1 --- categories/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 }