Merge branch 'testfix'

This commit is contained in:
Corey Oordt 2011-02-14 11:19:48 -05:00
commit 6023cc2a3c
7 changed files with 11 additions and 20 deletions

View file

@ -1,7 +1,7 @@
__version_info__ = {
'major': 0,
'minor': 5,
'micro': 0,
'micro': 1,
'releaselevel': 'final',
'serial': 0
}

View file

@ -4,6 +4,5 @@ Category 1
Category 2
Category 2-1
Category 2-1-1
Category 2-2
Category 3
Category 3-1

View file

@ -4,6 +4,5 @@ Category 1
Category 2
Category 2-1
Category 2-1-1
Category 2-2
Category 3
Category 3-1

View file

@ -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):
"""

View file

@ -1,4 +1,4 @@
from categories.tests import views
from categories.tests.category_import import *
from categories.tests.templatetags import *
__fixtures__ = ['categories.json']

View file

@ -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)

View file

@ -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<ul><li><a href="/categories/">Top</a>\n</li></ul>'
resp = self.render_template('{% load category_tags %}{% display_path_as_ul "/Rock" %}')
self.assertEqual(resp, rock_resp)
crock_resp = u'Rock\rRock &gt; 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 %}')