def test_parse_templates(self): """Make sure the parser grabs the l10n block content correctly.""" parser = L10nParser() blocks = parser.parse( 'foo bar bizzle what? ' '{% l10n baz, 20110914 %}' 'mumble' '{% was %}' 'wased' '{% endl10n %}' 'qux', only_blocks=True) baz = self._get_block(blocks, 'baz') self.assertEqual(baz['main'], 'mumble') self.assertEqual(baz['was'], 'wased') self.assertEqual(baz['version'], 20110914) blocks = parser.parse( 'foo bar bizzle what? ' '{% l10n baz, 20110914 %}' 'mumble' '{% endl10n %}' 'qux', only_blocks=True) baz = self._get_block(blocks, 'baz') self.assertEqual(baz['main'], 'mumble')
def test_parse_templates(self): """Make sure the parser grabs the l10n block content correctly.""" parser = L10nParser() blocks = parser.parse(""" foo bar bizzle what? {% l10n baz, 20110914 %} mumble {% was %} wased {% endl10n %} qux """, only_blocks=True) baz = self._get_block(blocks, 'baz') self.assertEqual(baz['main'], 'mumble') self.assertEqual(baz['was'], 'wased') self.assertEqual(baz['version'], 20110914) blocks = parser.parse(""" foo bar bizzle what? {% l10n baz locales=ru,bn-IN,fr 20110914 %} mumble {% endl10n %} qux """, only_blocks=True) baz = self._get_block(blocks, 'baz') self.assertEqual(baz['main'], 'mumble') self.assertEqual(baz['locales'], ['ru', 'bn-IN', 'fr']) self.assertEqual(baz['version'], 20110914)
def test_content_halt(self): """Make sure the parser will halt on the content block if told to do so.""" parser = L10nParser() content_str = 'foo bar {% block content %}baz{% endblock %} hello' last_token = None for token in parser.parse(content_str, halt_on_content=True): last_token = token self.assertEqual(last_token, False)
def test_parse_templates(self): parser = L10nParser() blocks = parser.parse('foo bar bizzle what? ' '{% l10n baz, 20110914 %}' 'mumble' '{% else %}' 'elsed' '{% endl10n %}' 'qux') baz = blocks['baz'] self.assertEqual(baz['main_content'], 'mumble') self.assertEqual(baz['else_content'], 'elsed') self.assertEqual(baz['version'], 20110914) blocks = parser.parse('foo bar bizzle what? ' '{% l10n baz, 20110914 %}' 'mumble' '{% endl10n %}' 'qux') baz = blocks['baz'] self.assertEqual(baz['main_content'], 'mumble')