# -*- coding: utf-8 -*-

from riot.layout import render_layout

def test_render_div():
    el = render_layout([
        'div', {}, []
    ])
    assert el
    assert el.uuid
    assert el.rows((10, )) == 1
    assert el.render((10, )).text == [
        u'          ',
    ]

def test_render_div_with_div_char():
    el = render_layout([
        'div', {
            'char': u'-',
            'top': 1,
            'bottom': 1
        }, []
    ])
    assert el
    assert el.rows((10, )) == 3 # top line + --------- + bottom line
    assert el.render((10, )).text == [
        '          ',
        '----------',
        '          ',
    ]

@@ -55,16 +55,30 @@
 r_layout
+, patch_layout
 %0A%0Adef te
@@ -90,36 +90,38 @@
 nder_div():%0A    
-el =
+assert
  render_layout(%5B
@@ -153,132 +153,124 @@
   %5D)
-%0A    assert el%0A    assert el.uuid%0A    assert el.rows((10, )) == 1%0A    assert el.render((10, )).text == %5B%0A        u' 
+ == %5B%0A        'div',%0A        %7B%0A            'div_char': u' ',%0A            'top': 0,%0A            'bottom': 0,%0A
         
  ',%0A
@@ -261,27 +261,25 @@
  0,%0A        
- ',
+%7D
 %0A    %5D%0A%0Adef 
@@ -449,173 +449,510 @@
   %5D)
-%0A    assert el%0A    assert el.rows((10, )) == 3 # top line + --------- + bottom line%0A    assert el.render((10, )).text == %5B%0A        '          ',%0A        '---------
+ == %5B%0A        'div',%0A        %7B%0A            'div_char': u'-',%0A            'top': 1,%0A            'bottom': 1,%0A        %7D%0A    %5D%0A%0Adef test_patch_div():%0A    # call div._invalidate()%0A    el1 = %5B%0A        'div',%0A        %7B%0A            'div_char': u' ',%0A            'top': 0,%0A            'bottom': 0,%0A        %7D%0A    %5D%0A    el2 = %5B%0A        'div',%0A        %7B%0A            'div_char': u'-',%0A            'top': 1,%0A            'bottom': 1,%0A        %7D%0A    %5D%0A    assert patch_layout(el1, el2) == %5B%0A        ('.div_char', u'
 -'
+)
 ,%0A  
@@ -961,20 +961,43 @@
     
-'          '
+('.top', 1),%0A        ('.bottom', 1)
 ,%0A  

Add patch div test.