예제 #1
0
    def test_get_par_count(self):
        self.assertEqual(3, text_utils.get_par_count("""
        <p>First paragraph</p>
        <p>Second paragraph</p>
        <p>Last paragraph</p>
        """))

        self.assertEqual(3, text_utils.get_par_count("""
        <p><br></p>
        <p>First paragraph</p>
        <p>Second paragraph</p>
        <p></p>
        <p>Last paragraph</p>
        <p>

        </p>
        """))

        self.assertEqual(0, text_utils.get_par_count("""
        <p>

        </p>
        """))

        self.assertEqual(0, text_utils.get_par_count("""
        <div></div>
        """))

        self.assertEqual(0, text_utils.get_par_count(None))
예제 #2
0
    def update_par_count_from_timeline_entry(self, entry, updates, update):
        """Generate and store the paragraph count from body_html"""

        if len(update.get('body_html') or '') > 0:
            entry['par_count'] = get_par_count(update['body_html'])
            updates['par_count'] = entry['par_count']
        else:
            entry['par_count'] = updates['par_count']

        if 'original_par_count' not in updates and entry['par_count'] > 0:
            updates['original_par_count'] = entry['par_count']