예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #21
0
파일: test_props.py 프로젝트: Khan/openpyxl
 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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #28
0
파일: test_props.py 프로젝트: Khan/openpyxl
 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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #36
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(os.path.join(DATADIR, "writer", "expected", "theme1.xml"), content)
예제 #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())
예제 #38
0
파일: test_style.py 프로젝트: Khan/openpyxl
 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())
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #44
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
        os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
예제 #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)
예제 #46
0
def test_write_theme():
    content = write_theme()
    assert_equals_file_content(
            os.path.join(DATADIR, 'writer', 'expected', 'theme1.xml'), content)
예제 #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)
예제 #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)