boxnotes2html

Convert Box's proprietary Box Notes to HTML, Markdown, or plain text
git clone git://git.alexwennerberg.com/boxnotes2html
Log | Files | Refs | README | LICENSE

test_table.py (1460B) - raw


      1 from boxnotes2html.table import Table
      2 
      3 
      4 class TestTable:
      5     
      6     def test_render_markdown(self):
      7         table = Table()
      8         table.add_data(1, 1, "Name")
      9         table.add_data(1, 2, "Country")
     10         table.add_data(1, 3, "Birthdate")
     11         
     12         table.add_data(2, 1, "Jill")
     13         table.add_data(2, 2, "Australia")
     14         table.add_data(2, 3, "2000-01-01")
     15         
     16         table.add_data(3, 1, "Alfonse")
     17         table.add_data(3, 2, "Chile")
     18         table.add_data(3, 3, "1981-02-04")
     19         
     20         expected = "| Name | Country | Birthdate |\n" + \
     21             "| :-- | :-- | :-- |\n" + \
     22             "| Jill | Australia | 2000-01-01 |\n" + \
     23             "| Alfonse | Chile | 1981-02-04 |\n"
     24         
     25         assert table.render_markdown() == expected
     26     
     27     def test_append_data_markdown(self):
     28         """
     29         Test that appending data to add_data works as expected and renders multiple lines properly.
     30         """
     31         table = Table()
     32         table.add_data(1, 1, "Name")
     33         table.add_data(1, 1, "(Full name)")
     34         table.add_data(1, 1, "(but with no spaces)")
     35         table.add_data(1, 1, "(as in full name camelcase)")
     36         
     37         table.add_data(2, 1, "JillFromDownUnder")
     38         
     39         expected = "| Name<br>(Full name)<br>(but with no spaces)<br>(as in full name camelcase) |\n" + \
     40             "| :-- |\n" + \
     41             "| JillFromDownUnder |\n"
     42         
     43         assert table.render_markdown() == expected