<commit_before>from StringIO import StringIO

from cms.tests.base import BaseCmsTestCase
from cms.management.commands import db_resync
from cms.models import Category, Post

from unicore.content import models as eg_models


class TestDBResync(BaseCmsTestCase):

    def setUp(self):
        self.workspace = self.mk_workspace()
        self.command = db_resync.Command()
        self.command.stdout = StringIO()

    def test_resync_empty_db(self):
        category1, category2 = self.create_categories(self.workspace)
        page1, page2 = self.create_pages(self.workspace)

        with self.settings(GIT_REPO_PATH=self.workspace.working_dir):
            # run the command
            self.command.handle()
            output = self.command.stdout.getvalue()

        self.assertTrue(
            'Deleted unicore.content.models.Page: %s' % (page1.uuid,)
            in output)
        self.assertTrue(
            'Deleted unicore.content.models.Page: %s' % (page2.uuid,)
            in output)<commit_msg>pyflakes fix<commit_after>from StringIO import StringIO

from cms.tests.base import BaseCmsTestCase
from cms.management.commands import db_resync
from cms.models import Category, Post


class TestDBResync(BaseCmsTestCase):

    def setUp(self):
        self.workspace = self.mk_workspace()
        self.command = db_resync.Command()
        self.command.stdout = StringIO()

    def test_resync_empty_db(self):
        category1, category2 = self.create_categories(self.workspace)
        page1, page2 = self.create_pages(self.workspace)

        with self.settings(GIT_REPO_PATH=self.workspace.working_dir):
            # run the command
            self.command.handle()
            output = self.command.stdout.getvalue()

        self.assertTrue(
            'Deleted unicore.content.models.Page: %s' % (page1.uuid,)
            in output)
        self.assertTrue(
            'Deleted unicore.content.models.Page: %s' % (page2.uuid,)
            in output)
{'fraction_non_alphanumeric': 0.09482758620689655, 'fraction_numerical': 0.006085192697768763, 'mean_word_length': 2.7086466165413534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4661632', 'n_tokens_mistral': 592, 'n_tokens_neox': 590, 'n_words': 120}