Esempio n. 1
0
 def test_A(self):
     self.assertEqual(A('<>', _a='1', _b='2').xml(),
                      '<a a="1" b="2">&lt;&gt;</a>')
     self.assertEqual(A('a', cid='b').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>')
     self.assertEqual(A('a', callback='b', _id='c').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="c">a</a>')
     # Callback with no id trigger web2py_uuid() call
     from html import web2pyHTMLParser
     a = A('a', callback='b').xml()
     for tag in web2pyHTMLParser(a).tree.elements('a'):
         uuid_generated = tag.attributes['_id']
     self.assertEqual(a,
                      '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="{id}">a</a>'.format(id=uuid_generated))
     self.assertEqual(A('a', delete='tr').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_remove="tr">a</a>')
     self.assertEqual(A('a', _id='b', target='<self>').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_target="b" id="b">a</a>')
     self.assertEqual(A('a', component='b').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="GET" href="b">a</a>')
     self.assertEqual(A('a', _id='b', callback='c', noconfirm=True).xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="POST" href="c" id="b">a</a>')
     self.assertEqual(A('a', cid='b').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>')
     self.assertEqual(A('a', cid='b', _disable_with='processing...').xml(),
                      '<a data-w2p_disable_with="processing..." data-w2p_method="GET" data-w2p_target="b">a</a>')
     self.assertEqual(A('a', callback='b', delete='tr', noconfirm=True, _id='c').xml(),
                      '<a data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>')
     self.assertEqual(A('a', callback='b', delete='tr', confirm='Are you sure?', _id='c').xml(),
                      '<a data-w2p_confirm="Are you sure?" data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>')
 def test_A(self):
     self.assertEqual(
         A('<>', _a='1', _b='2').xml(),
         '<a a="1" b="2">&lt;&gt;</a>'
         )
     self.assertEqual(
         A('a', cid='b').xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>'
         )
     self.assertEqual(
         A('a', callback='b', _id='c').xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="c">a</a>'
         )
     # Callback with no id trigger web2py_uuid() call
     from html import web2pyHTMLParser
     a = A('a', callback='b').xml()
     for tag in web2pyHTMLParser(a).tree.elements('a'):
         uuid_generated = tag.attributes['_id']
     self.assertEqual(a,
                      '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="{id}">a</a>'.format(id=uuid_generated))
     self.assertEqual(
         A('a', delete='tr').xml(),
         '<a data-w2p_disable_with="default" data-w2p_remove="tr">a</a>'
         )
     self.assertEqual(
         A('a', _id='b', target='<self>').xml(),
         '<a data-w2p_disable_with="default" data-w2p_target="b" id="b">a</a>'
         )
     self.assertEqual(
         A('a', component='b').xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="GET" href="b">a</a>'
         )
     self.assertEqual(
         A('a', _id='b', callback='c', noconfirm=True).xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="POST" href="c" id="b">a</a>'
         )
     self.assertEqual(
         A('a', cid='b').xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>'
         )
     self.assertEqual(
         A('a', cid='b', _disable_with='processing...').xml(),
         '<a data-w2p_disable_with="processing..." data-w2p_method="GET" data-w2p_target="b">a</a>'
         )
     self.assertEqual(
         A('a', callback='b', delete='tr', noconfirm=True, _id='c').xml(),
         '<a data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>'
         )
     self.assertEqual(
         A('a', callback='b', delete='tr', confirm='Are you sure?', _id='c').xml(),
         '<a data-w2p_confirm="Are you sure?" data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>'
         )
Esempio n. 3
0
    def test_A(self):
        self.assertEqual(A("<>", _a="1", _b="2").xml(), '<a a="1" b="2">&lt;&gt;</a>')
        self.assertEqual(
            A("a", cid="b").xml(), '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>'
        )
        self.assertEqual(
            A("a", callback="b", _id="c").xml(),
            '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="c">a</a>',
        )
        # Callback with no id trigger web2py_uuid() call
        from html import web2pyHTMLParser

        a = A("a", callback="b").xml()
        for tag in web2pyHTMLParser(a).tree.elements("a"):
            uuid_generated = tag.attributes["_id"]
        self.assertEqual(
            a,
            '<a data-w2p_disable_with="default" data-w2p_method="POST" href="b" id="{id}">a</a>'.format(
                id=uuid_generated
            ),
        )
        self.assertEqual(A("a", delete="tr").xml(), '<a data-w2p_disable_with="default" data-w2p_remove="tr">a</a>')
        self.assertEqual(
            A("a", _id="b", target="<self>").xml(),
            '<a data-w2p_disable_with="default" data-w2p_target="b" id="b">a</a>',
        )
        self.assertEqual(
            A("a", component="b").xml(), '<a data-w2p_disable_with="default" data-w2p_method="GET" href="b">a</a>'
        )
        self.assertEqual(
            A("a", _id="b", callback="c", noconfirm=True).xml(),
            '<a data-w2p_disable_with="default" data-w2p_method="POST" href="c" id="b">a</a>',
        )
        self.assertEqual(
            A("a", cid="b").xml(), '<a data-w2p_disable_with="default" data-w2p_method="GET" data-w2p_target="b">a</a>'
        )
        self.assertEqual(
            A("a", cid="b", _disable_with="processing...").xml(),
            '<a data-w2p_disable_with="processing..." data-w2p_method="GET" data-w2p_target="b">a</a>',
        )
        self.assertEqual(
            A("a", callback="b", delete="tr", noconfirm=True, _id="c").xml(),
            '<a data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>',
        )
        self.assertEqual(
            A("a", callback="b", delete="tr", confirm="Are you sure?", _id="c").xml(),
            '<a data-w2p_confirm="Are you sure?" data-w2p_disable_with="default" data-w2p_method="POST" data-w2p_remove="tr" href="b" id="c">a</a>',
        )