def test_generate_csv_colspans():
    with open("test/fixtures/simple-table-colspans.html") as fd:
        grid_rows = grid_rows_from_string(fd.read())

    with mock.patch("create_downloads.CsvOutput._send_row") as _send_row:
        with CsvOutput("test/test.csv") as csv_output:
            for row in grid_rows:
                csv_output.write_row(row)

        from mock import call
        expected = [
            call([u'Name: \u201cBlad1\u201d', u'Name: \u201cBlad1\u201d',
                  u'Name: \u201cBlad1\u201d', u'Name: \u201cBlad1\u201d']),
            call(['Table: 1', 'Table: 1', 'Table: 1', 'Table: 1']),
            call(['', '', '', '']),
            call(['Port', '31 December 2012', '31 January 2013',
                  'Difference']),
            call(['', '', '', '']),
            call(['Antwerp', '4827966.66667', '4947533.33333',
                  '119566.666667']),
            call(['Bremen', '1265600.0', '1344250.0', '78650.0']),
            call(['Hamburg', '1593400.0', '1653916.66667', '60516.6666667']),
            call(['Genova', '934993.0', '947459.0', '12466.0']),
            call(['Le Havre', '445833.333333', '479983.333333', '34150.0']),
            call(['Trieste', '695243.0', '702157.0', '6914.0']),
            call(['Total Europe', '9763036.0', '10075299.3333',
                  '312263.333333'])]

        # The intent of this test is to ensure that colspans are correctly
        # copied to all of the destination cells which are overlapped by it.
        assert_equal(expected, _send_row.call_args_list)
def test_generate_excel_colspans_complex():
    # This test doesn't actually check the output, it just exercises the code.
    # :(

    with open("test/fixtures/more-complicated-colspan.html") as fd:
        grid_rows = grid_rows_from_string(fd.read())

    with ExcelOutput("test/test.xls") as excel_output:
        add_row = excel_output.add_sheet("test_sheet")

        for row in grid_rows:
            add_row(row)