Example #1
0
def test_short_number():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = 1234567890
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'short_number.xml'), content)
Example #2
0
def test_write_bool():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("F42").value = False
    ws.cell("F43").value = True
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_bool.xml"), content)
Example #3
0
def test_write_hidden_worksheet():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.sheet_state = ws.SHEETSTATE_HIDDEN
    ws.cell("F42").value = "hello"
    content = write_worksheet(ws, {"hello": 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1.xml"), content)
Example #4
0
def test_freeze_panes_both():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("F42").value = "hello"
    ws.freeze_panes = "D4"
    content = write_worksheet(ws, {"hello": 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_freeze_panes_both.xml"), content)
Example #5
0
def test_write_style():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("F1").value = "13%"
    style_id_by_hash = StyleWriter(wb).get_style_by_hash()
    content = write_worksheet(ws, {}, style_id_by_hash)
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_style.xml"), content)
Example #6
0
def test_short_number():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = 1234567890
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'short_number.xml'), content)
Example #7
0
def test_decimal():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = decimal.Decimal('3.14')
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'decimal.xml'), content)
Example #8
0
def test_write_worksheet():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F42').value = 'hello'
    content = write_worksheet(ws, {'hello': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1.xml'), content)
Example #9
0
def test_decimal():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = decimal.Decimal('3.14')
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'decimal.xml'), content)
Example #10
0
 def test_write_properties_app(self):
     wb = Workbook()
     wb.create_sheet()
     wb.create_sheet()
     content = write_properties_app(wb)
     assert_equals_file_content(
         os.path.join(DATADIR, 'writer', 'expected', 'app.xml'), content)
Example #11
0
def test_write_height():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("F1").value = 10
    ws.row_dimensions[ws.cell("F1").row].height = 30
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_height.xml"), content)
Example #12
0
def test_write_worksheet():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F42').value = 'hello'
    content = write_worksheet(ws, {'hello': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1.xml'), content)
Example #13
0
def test_write_hyperlink():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("A1").value = "test"
    ws.cell("A1").hyperlink = "http://test.com"
    content = write_worksheet(ws, {"test": 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_hyperlink.xml"), content)
Example #14
0
def test_write_hyperlink():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = "test"
    ws.cell('A1').hyperlink = "http://test.com"
    content = write_worksheet(ws, {'test': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
        'sheet1_hyperlink.xml'), content)
Example #15
0
def test_write_hyperlink():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('A1').value = "test"
    ws.cell('A1').hyperlink = "http://test.com"
    content = write_worksheet(ws, {'test': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
        'sheet1_hyperlink.xml'), content)
Example #16
0
def test_write_height():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F1').value = 10
    ws.row_dimensions[ws.cell('F1').row].height = 30
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_height.xml'), content)
Example #17
0
def test_write_bool():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F42').value = False
    ws.cell('F43').value = True
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_bool.xml'), content)
Example #18
0
def test_write_style():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F1').value = '13%'
    style_id_by_hash = StyleWriter(wb).get_style_by_hash()
    content = write_worksheet(ws, {}, style_id_by_hash)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_style.xml'), content)
Example #19
0
def test_write_formula():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("F1").value = 10
    ws.cell("F2").value = 32
    ws.cell("F3").value = "=F1+F2"
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_formula.xml"), content)
Example #20
0
 def test_write_properties_core(self):
     self.prop.creator = 'TEST_USER'
     self.prop.last_modified_by = 'SOMEBODY'
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     assert_equals_file_content(
         os.path.join(DATADIR, 'writer', 'expected', 'core.xml'), content)
Example #21
0
 def test_write_properties_app(self):
     wb = Workbook()
     wb.create_sheet()
     wb.create_sheet()
     content = write_properties_app(wb)
     assert_equals_file_content(
             os.path.join(DATADIR, 'writer', 'expected', 'app.xml'),
             content)
Example #22
0
def test_write_content_types():
    wb = Workbook()
    wb.create_sheet()
    wb.create_sheet()
    content = write_content_types(wb)
    reference_file = os.path.join(DATADIR, 'writer', 'expected',
            '[Content_Types].xml')
    assert_equals_file_content(reference_file, content)
Example #23
0
def test_write_content_types():
    wb = Workbook()
    wb.create_sheet()
    wb.create_sheet()
    content = write_content_types(wb)
    reference_file = os.path.join(DATADIR, 'writer', 'expected',
                                  '[Content_Types].xml')
    assert_equals_file_content(reference_file, content)
Example #24
0
def test_write_bool():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F42').value = False
    ws.cell('F43').value = True
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_bool.xml'), content)
Example #25
0
def test_write_style():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F1').value = '13%'
    style_id_by_hash = StyleWriter(wb).get_style_by_hash()
    content = write_worksheet(ws, {}, style_id_by_hash)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_style.xml'), content)
Example #26
0
def test_write_formula():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F1').value = 10
    ws.cell('F2').value = 32
    ws.cell('F3').value = '=F1+F2'
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_formula.xml'), content)
Example #27
0
def test_write_formula():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell('F1').value = 10
    ws.cell('F2').value = 32
    ws.cell('F3').value = '=F1+F2'
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_formula.xml'), content)
Example #28
0
 def test_write_properties_core(self):
     self.prop.creator = 'TEST_USER'
     self.prop.last_modified_by = 'SOMEBODY'
     self.prop.created = datetime(2010, 4, 1, 20, 30, 00)
     self.prop.modified = datetime(2010, 4, 5, 14, 5, 30)
     content = write_properties_core(self.prop)
     assert_equals_file_content(
             os.path.join(DATADIR, 'writer', 'expected', 'core.xml'),
             content)
Example #29
0
def test_write_auto_filter():
    wb = Workbook()
    ws = wb.worksheets[0]
    ws.cell("F42").value = "hello"
    ws.auto_filter = "A1:F1"
    content = write_worksheet(ws, {"hello": 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_auto_filter.xml"), content)

    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "workbook_auto_filter.xml"), content)
Example #30
0
def test_write_auto_filter():
    wb = Workbook()
    ws = wb.worksheets[0]
    ws.cell('F42').value = 'hello'
    ws.auto_filter = 'A1:F1'
    content = write_worksheet(ws, {'hello': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_auto_filter.xml'), content)

    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'workbook_auto_filter.xml'), content)
Example #31
0
def test_write_auto_filter():
    wb = Workbook()
    ws = wb.worksheets[0]
    ws.cell('F42').value = 'hello'
    ws.auto_filter = 'A1:F1'
    content = write_worksheet(ws, {'hello': 0}, {})
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_auto_filter.xml'), content)

    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'workbook_auto_filter.xml'), content)
Example #32
0
def test_write_hyperlink_rels():
    wb = Workbook()
    ws = wb.create_sheet()
    eq_(0, len(ws.relationships))
    ws.cell("A1").value = "test"
    ws.cell("A1").hyperlink = "http://test.com/"
    eq_(1, len(ws.relationships))
    ws.cell("A2").value = "test"
    ws.cell("A2").hyperlink = "http://test2.com/"
    eq_(2, len(ws.relationships))
    content = write_worksheet_rels(ws, 1)
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sheet1_hyperlink.xml.rels"), content)
Example #33
0
def test_write_hyperlink_rels():
    wb = Workbook()
    ws = wb.create_sheet()
    eq_(0, len(ws.relationships))
    ws.cell('A1').value = "test"
    ws.cell('A1').hyperlink = "http://test.com/"
    eq_(1, len(ws.relationships))
    ws.cell('A2').value = "test"
    ws.cell('A2').hyperlink = "http://test2.com/"
    eq_(2, len(ws.relationships))
    content = write_worksheet_rels(ws, 1)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sheet1_hyperlink.xml.rels'), content)
Example #34
0
def test_write_workbook():
    wb = Workbook()
    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "workbook.xml"), content)
Example #35
0
def test_write_root_rels():
    wb = Workbook()
    content = write_root_rels(wb)
    reference_file = os.path.join(DATADIR, 'writer', 'expected', '.rels')
    assert_equals_file_content(reference_file, content)
Example #36
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "theme1.xml"), content)
Example #37
0
 def test_write_style_table(self):
     reference_file = os.path.join(DATADIR, 'writer', 'expected',
                                   'simple-styles.xml')
     assert_equals_file_content(reference_file, self.writer.write_table())
Example #38
0
 def test_write_style_table(self):
     reference_file = os.path.join(DATADIR, 'writer', 'expected', 'simple-styles.xml')
     assert_equals_file_content(reference_file, self.writer.write_table())
Example #39
0
def test_write_string_table():
    table = {'hello': 1, 'world': 2, 'nice': 3}
    content = write_string_table(table)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sharedStrings.xml'), content)
Example #40
0
def test_write_workbook():
    wb = Workbook()
    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'workbook.xml'), content)
Example #41
0
def test_write_root_rels():
    wb = Workbook()
    content = write_root_rels(wb)
    reference_file = os.path.join(DATADIR, 'writer', 'expected', '.rels')
    assert_equals_file_content(reference_file, content)
Example #42
0
def test_write_string_table():
    table = {'hello': 1, 'world': 2, 'nice': 3}
    content = write_string_table(table)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'sharedStrings.xml'), content)
Example #43
0
def test_short_number():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("A1").value = 1234567890
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "short_number.xml"), content)
Example #44
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
        os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
Example #45
0
def test_write_string_table():
    table = {"hello": 1, "world": 2, "nice": 3}
    content = write_string_table(table)
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "sharedStrings.xml"), content)
Example #46
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
            os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
Example #47
0
def test_write_workbook():
    wb = Workbook()
    content = write_workbook(wb)
    assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \
            'workbook.xml'), content)
Example #48
0
def test_decimal():
    wb = Workbook()
    ws = wb.create_sheet()
    ws.cell("A1").value = decimal.Decimal("3.14")
    content = write_worksheet(ws, {}, {})
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "decimal.xml"), content)