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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def test_write_workbook(): wb = Workbook() content = write_workbook(wb) assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "workbook.xml"), content)
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)
def test_write_theme(): content = write_theme() assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "theme1.xml"), content)
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())
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)
def test_write_workbook(): wb = Workbook() content = write_workbook(wb) assert_equals_file_content(os.path.join(DATADIR, 'writer', 'expected', \ 'workbook.xml'), content)
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)
def test_write_theme(): content = write_theme() assert_equals_file_content( os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
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)
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)