Exemplo n.º 1
0
 def test_translate_xml_text_entity(self):
     """ Test xml_translate() on plain text with HTML escaped entities. """
     terms = []
     source = "Blah blah blah"
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, [source])
Exemplo n.º 2
0
 def test_translate_html(self):
     """ Test xml_translate() and html_translate() with <i> elements. """
     source = """<i class="fa-check"></i>"""
     result = xml_translate(lambda term: term, source)
     self.assertEquals(result, """<i class="fa-check"/>""")
     result = html_translate(lambda term: term, source)
     self.assertEquals(result, source)
Exemplo n.º 3
0
 def test_translate_xml_text(self):
     """ Test xml_translate() on plain text. """
     terms = []
     source = "Blah blah blah"
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, [source])
Exemplo n.º 4
0
 def test_translate_xml_text_entity(self):
     """ Test xml_translate() on plain text with HTML escaped entities. """
     terms = []
     source = "Blah&amp;nbsp;blah&amp;nbsp;blah"
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, [source])
Exemplo n.º 5
0
 def test_translate_html(self):
     """ Test xml_translate() and html_translate() with <i> elements. """
     source = """<i class="fa-check"></i>"""
     result = xml_translate(lambda term: term, source)
     self.assertEquals(result, """<i class="fa-check"/>""")
     result = html_translate(lambda term: term, source)
     self.assertEquals(result, source)
Exemplo n.º 6
0
 def test_translate_xml_text(self):
     """ Test xml_translate() on plain text. """
     terms = []
     source = "Blah blah blah"
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, [source])
Exemplo n.º 7
0
 def test_translate_xml_attribute(self):
     """ Test xml_translate() with <attribute> elements. """
     terms = []
     source = """<field name="foo" position="attributes">
                     <attribute name="string">Translate this</attribute>
                     <attribute name="option">Do not translate this</attribute>
                 </field>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["Translate this"])
Exemplo n.º 8
0
 def test_translate_xml_attribute(self):
     """ Test xml_translate() with <attribute> elements. """
     terms = []
     source = """<field name="foo" position="attributes">
                     <attribute name="string">Translate this</attribute>
                     <attribute name="option">Do not translate this</attribute>
                 </field>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ['Translate this'])
Exemplo n.º 9
0
 def test_translate_xml_base(self):
     """ Test xml_translate() without formatting elements. """
     terms = []
     source = """<form string="Form stuff">
                     <h1>Blah blah blah</h1>
                     Put some more text here
                     <field name="foo"/>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["Form stuff", "Blah blah blah", "Put some more text here"])
Exemplo n.º 10
0
 def test_translate_xml_off(self):
     """ Test xml_translate() with attribute translate="off". """
     terms = []
     source = """<div>
                     stuff before
                     <div translation="off">Do not translate this</div>
                     stuff after
                 </div>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ['stuff before', 'stuff after'])
Exemplo n.º 11
0
 def test_translate_xml_off(self):
     """ Test xml_translate() with attribute translate="off". """
     terms = []
     source = """<div>
                     stuff before
                     <div translation="off">Do not translate this</div>
                     stuff after
                 </div>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["stuff before", "stuff after"])
Exemplo n.º 12
0
 def test_translate_xml_t(self):
     """ Test xml_translate() with t-* attributes. """
     terms = []
     source = """<t t-name="stuff">
                     stuff before
                     <span t-field="o.name"/>
                     stuff after
                 </t>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["stuff before", "stuff after"])
Exemplo n.º 13
0
 def test_translate_xml_inline2(self):
     """ Test xml_translate() with formatting elements embedding other elements. """
     terms = []
     source = """<form string="Form stuff">
                     <b><h1>Blah <i>blah</i> blah</h1></b>
                     Put <em>some <b>more text</b></em> here
                     <field name="foo"/>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["Form stuff", "Blah <i>blah</i> blah", "Put <em>some <b>more text</b></em> here"])
Exemplo n.º 14
0
 def test_translate_xml_t(self):
     """ Test xml_translate() with t-* attributes. """
     terms = []
     source = """<t t-name="stuff">
                     stuff before
                     <span t-field="o.name"/>
                     stuff after
                 </t>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ['stuff before', 'stuff after'])
Exemplo n.º 15
0
 def test_translate_xml_inline2(self):
     """ Test xml_translate() with formatting elements embedding other elements. """
     terms = []
     source = """<form string="Form stuff">
                     <b><h1>Blah <i>blah</i> blah</h1></b>
                     Put <em>some <b>more text</b></em> here
                     <field name="foo"/>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms,
         ['Form stuff', 'Blah <i>blah</i> blah', 'Put <em>some <b>more text</b></em> here'])
Exemplo n.º 16
0
 def test_translate_xml_base(self):
     """ Test xml_translate() without formatting elements. """
     terms = []
     source = """<form string="Form stuff">
                     <h1>Blah blah blah</h1>
                     Put some more text here
                     <field name="foo"/>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms,
         ['Form stuff', 'Blah blah blah', 'Put some more text here'])
Exemplo n.º 17
0
 def test_translate_xml_inline1(self):
     """ Test xml_translate() with formatting elements. """
     terms = []
     source = """<form string="Form stuff">
                     <h1>Blah <i>blah</i> blah</h1>
                     Put some <b>more text</b> here
                     <field name="foo"/>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms,
         ['Form stuff', 'Blah <i>blah</i> blah', 'Put some <b>more text</b> here'])
Exemplo n.º 18
0
 def test_translate_xml_inline3(self):
     """ Test xml_translate() with formatting elements without actual text. """
     terms = []
     source = """<form string="Form stuff">
                     <div>
                         <span class="before"/>
                         <h1>Blah blah blah</h1>
                         <span class="after">
                             <i class="hack"/>
                         </span>
                     </div>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ["Form stuff", "Blah blah blah"])
Exemplo n.º 19
0
 def test_translate_xml_inline3(self):
     """ Test xml_translate() with formatting elements without actual text. """
     terms = []
     source = """<form string="Form stuff">
                     <div>
                         <span class="before"/>
                         <h1>Blah blah blah</h1>
                         <span class="after">
                             <i class="hack"/>
                         </span>
                     </div>
                 </form>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ['Form stuff', 'Blah blah blah'])
Exemplo n.º 20
0
 def test_translate_xml_a(self):
     """ Test xml_translate() with <a> elements. """
     terms = []
     source = """<t t-name="stuff">
                     <ul class="nav navbar-nav">
                         <li>
                             <a class="oe_menu_leaf" href="/web#menu_id=42&amp;action=54">
                                 <span class="oe_menu_text">Blah</span>
                             </a>
                         </li>
                         <li class="dropdown" id="menu_more_container" style="display: none;">
                             <a class="dropdown-toggle" data-toggle="dropdown" href="#">More <b class="caret"/></a>
                             <ul class="dropdown-menu" id="menu_more"/>
                         </li>
                     </ul>
                 </t>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms, ['<span class="oe_menu_text">Blah</span>', 'More <b class="caret"/>'])
Exemplo n.º 21
0
 def test_translate_xml_a(self):
     """ Test xml_translate() with <a> elements. """
     terms = []
     source = """<t t-name="stuff">
                     <ul class="nav navbar-nav">
                         <li>
                             <a class="oe_menu_leaf" href="/web#menu_id=42&amp;action=54">
                                 <span class="oe_menu_text">Blah</span>
                             </a>
                         </li>
                         <li class="dropdown" id="menu_more_container" style="display: none;">
                             <a class="dropdown-toggle" data-toggle="dropdown" href="#">More <b class="caret"/></a>
                             <ul class="dropdown-menu" id="menu_more"/>
                         </li>
                     </ul>
                 </t>"""
     result = xml_translate(terms.append, source)
     self.assertEquals(result, source)
     self.assertItemsEqual(terms,
         ['<span class="oe_menu_text">Blah</span>', 'More <b class="caret"/>'])
Exemplo n.º 22
0
 def test_translate_xml_text_entity_unescaped(self):
     """ Test xml_translate() on plain text with HTML entities. """
     terms = []
     source = "Blah&nbsp;blah&nbsp;blah"
     with self.assertRaises(XMLSyntaxError):
         xml_translate(terms.append, source)
Exemplo n.º 23
0
 def test_translate_xml_text_entity_unescaped(self):
     """ Test xml_translate() on plain text with HTML entities. """
     terms = []
     source = "Blah&nbsp;blah&nbsp;blah"
     with self.assertRaises(XMLSyntaxError):
         xml_translate(terms.append, source)