Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 36
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "theme1.xml"), content)
Esempio n. 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())
Esempio n. 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())
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 44
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
        os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
Esempio n. 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)
Esempio n. 46
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
            os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
Esempio n. 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)
Esempio n. 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)