Added test for replace_text command

This commit is contained in:
Karl Hobley 2014-05-30 15:49:21 +01:00
parent e9ce499d5a
commit 86969e9df3
2 changed files with 18 additions and 1 deletions

View file

@ -24,7 +24,7 @@ class Command(BaseCommand):
revision.save(update_fields=['content_json'])
for content_type in get_page_types():
print "scanning %s" % content_type.name
self.stdout.write("scanning %s" % content_type.name)
page_class = content_type.model_class()
try:

View file

@ -841,3 +841,20 @@ class TestMovePagesCommand(TestCase):
# Check that all pages moved
for page_id in page_ids:
self.assertEqual(Page.objects.get(id=page_id).get_parent(), about_us)
class TestReplaceTextCommand(TestCase):
fixtures = ['test.json']
def run_command(self, from_text, to_text):
management.call_command('replace_text', from_text, to_text, interactive=False, stdout=StringIO())
def test_replace_text(self):
# Check that the christmas page is definitely about christmas
self.assertEqual(Page.objects.get(url_path='/home/events/christmas/').title, "Christmas")
# Make it about easter
self.run_command("Christmas", "Easter")
# Check that its now about easter
self.assertEqual(Page.objects.get(url_path='/home/events/christmas/').title, "Easter")