Skip to content

Commit

Permalink
Merge pull request #2769 from yakky/feature/fix_loaddata_rebased
Browse files Browse the repository at this point in the history
Fix loaddata
  • Loading branch information
digi604 committed Mar 1, 2014
2 parents dbeddd1 + 8562511 commit 4339013
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cms/signals/page.py
Expand Up @@ -22,7 +22,7 @@ def pre_save_page(instance, **kwargs):
def post_save_page(instance, **kwargs):
if not kwargs.get('raw'):
instance.rescan_placeholders()
update_home(instance)
update_home(instance)
if instance.old_page is None or instance.old_page.parent_id != instance.parent_id or instance.is_home != instance.old_page.is_home:
for page in instance.get_descendants(include_self=True):
for title in page.title_set.all().select_related('page'):
Expand Down
11 changes: 10 additions & 1 deletion cms/tests/fixture_loading.py
Expand Up @@ -11,7 +11,7 @@

from cms.test_utils.fixtures.navextenders import NavextendersFixture
from cms.test_utils.testcases import SettingsOverrideTestCase
from cms.models import Page
from cms.models import Page, Placeholder, CMSPlugin


class FixtureTestCase(NavextendersFixture, SettingsOverrideTestCase):
Expand All @@ -25,13 +25,22 @@ def test_fixture_load(self):
output = StringIO()
dump = tempfile.mkstemp(".json")
call_command('dumpdata', 'cms', indent=3, stdout=output)
original_ph = Placeholder.objects.count()
original_pages = Page.objects.count()
original_plugins = CMSPlugin.objects.count()
Page.objects.all().delete()
output.seek(0)
with codecs.open(dump[1], 'w', 'utf-8') as dumpfile:
dumpfile.write(output.read())

self.assertEqual(0, Page.objects.count())
self.assertEqual(0, Placeholder.objects.count())
# Transaction disable, otherwise the connection it the test would be
# isolated from the data loaded in the different command connection
call_command('loaddata', dump[1], commit=False, stdout=output)
self.assertEqual(10, Page.objects.count())
self.assertEqual(original_pages, Page.objects.count())
# Placeholder number may differ if signals does not correctly handle
# load data command
self.assertEqual(original_ph, Placeholder.objects.count())
self.assertEqual(original_plugins, CMSPlugin.objects.count())

0 comments on commit 4339013

Please sign in to comment.