Beispiel #1
0
 def test_replace_display_form(self):
     cell = Cell()
     cell.set_value(100.)
     cell.display_form = "100,00"
     self.assertEqual(cell.plaintext(), "100,00")
     cell.display_form = "200,00"
     self.assertEqual(cell.plaintext(), "200,00")
Beispiel #2
0
 def test_replace_display_form(self):
     cell = Cell()
     cell.set_value(100.)
     cell.display_form = "100,00"
     self.assertEqual(cell.plaintext(), "100,00")
     cell.display_form = "200,00"
     self.assertEqual(cell.plaintext(), "200,00")
Beispiel #3
0
 def test_set_new_string(self):
     cell = Cell(value_type='string')
     cell.append_text('test')
     self.assertEqual(cell.plaintext(), 'test')
     self.assertEqual(cell.value, 'test')
Beispiel #4
0
 def test_set_cell_row_index_error(self):
     with self.assertRaises(IndexError):
         self.table[10, 0] = Cell()
Beispiel #5
0
 def test_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Beispiel #6
0
 def test_set_time_value(self):
     cell = Cell()
     cell.set_value('PT0H05M00,0000S', 'time')
     self.assertEqual(cell.value_type, 'time')
     self.assertEqual(cell.value, 'PT0H05M00,0000S')
Beispiel #7
0
 def test_init_no_args(self):
     cell = Cell()
     self.assertEqual(cell.value_type, None)
     self.assertEqual(cell.value, None)
     self.assertEqual(cell.plaintext(), "")
Beispiel #8
0
 def test_set_float_with_type(self):
     cell = Cell()
     cell.set_value('100', 'float')
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.)
Beispiel #9
0
 def test_set_false_boolean_without_type(self):
     cell = Cell()
     cell.set_value(False)
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, False)
Beispiel #10
0
 def test_constructor_with_style_name(self):
     cell = Cell(style_name='astyle')
     self.assertEqual('astyle', cell.style_name)
Beispiel #11
0
 def test_float_as_string(self):
     cell = Cell(1.0, 'string')
     self.assertEqual(cell.value_type, 'string')
     self.assertEqual(cell.value, '1.0')
Beispiel #12
0
 def test_float_no_type(self):
     cell = Cell(1.0)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 1.0)
Beispiel #13
0
 def test_float_with_type(self):
     cell = Cell(1.0, 'currency')
     self.assertEqual(cell.value_type, 'currency')
     self.assertEqual(cell.value, 1.0)
Beispiel #14
0
 def test_string(self):
     cell = Cell('text')
     self.assertEqual(cell.value_type, 'string')
     self.assertEqual(cell.value, 'text')
Beispiel #15
0
 def test_init_type_without_value(self):
     cell = Cell(value_type='float')
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, None)
     self.assertEqual(cell.plaintext(), "")
Beispiel #16
0
 def test_init_value_without_type(self):
     cell = Cell(value=100)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.)
Beispiel #17
0
 def test_append_two_strings(self):
     cell = Cell('test1')
     cell.append_text('test2')
     self.assertEqual(cell.plaintext(), 'test1test2')
     self.assertEqual(cell.value, 'test1test2')
Beispiel #18
0
 def test_boolean_true(self):
     cell = Cell(True)
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, True)
Beispiel #19
0
 def test_replace_two_paragraphs_by_new_string(self):
     cell = Cell('test1')
     cell.append(Paragraph('test2'))
     cell.set_value('new content')
     self.assertEqual('new content', cell.value)
Beispiel #20
0
 def test_boolean_false(self):
     cell = Cell(False)
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, False)
Beispiel #21
0
 def test_set_int_without_type(self):
     cell = Cell()
     cell.set_value(100)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.)
Beispiel #22
0
 def test_time_value(self):
     cell = Cell('PT0H05M00,0000S', 'time')
     self.assertEqual(cell.value_type, 'time')
     self.assertEqual(cell.value, 'PT0H05M00,0000S')
Beispiel #23
0
 def test_error_set_None_value(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(None)
Beispiel #24
0
 def test_date_value(self):
     cell = Cell('2011-01-29T12:00:01', 'date')
     self.assertEqual(cell.value_type, 'date')
     self.assertEqual(cell.value, '2011-01-29T12:00:01')
Beispiel #25
0
 def test_init_no_args(self):
     cell = Cell()
     self.assertEqual(cell.value_type, None)
     self.assertEqual(cell.value, None)
     self.assertEqual(cell.plaintext(), "")
Beispiel #26
0
 def test_wrapped_object(self):
     cell = Cell(Paragraph('text'))
     self.assertEqual(cell.value_type, 'string')
     self.assertEqual(cell.value, 'text')
     self.assertEqual(cell[0].kind, 'Paragraph')
Beispiel #27
0
 def test_set_content_validation_name(self):
     cell = Cell()
     cell.content_validation_name = 'validation'
     self.assertEqual(cell.content_validation_name, 'validation')
     self.assertEqual(cell.get_attr(CN('table:content-validation-name')), 'validation',
                      'wrong tag name')
Beispiel #28
0
 def test_Cell_is_kind_of_Cell(self):
     cell = Cell()
     covered_cell = Cell()
     self.assertEqual(covered_cell.kind, cell.kind)
Beispiel #29
0
 def test_set_cell_neg_row_index(self):
     self.table[-1, 0] = Cell('Textcell')
     cell = self.table[3, 0]
     self.assertEqual(cell.plaintext(), "Textcell")
Beispiel #30
0
 def test_is_covered(self):
     cell = Cell()
     self.assertFalse(cell.covered)
Beispiel #31
0
 def test_check_invalid_value_type(self):
     cell = Cell()
     with self.assertRaises(TypeError):
         cell.set_value('', value_type='invalid')
Beispiel #32
0
 def test_uncover_cell(self):
     cell = Cell()
     cell._set_covered(False)
     self.assertFalse(cell.covered)
     self.assertEqual(cell.TAG, Cell.TAG)
Beispiel #33
0
 def test_append_text_accept_style_name(self):
     cell = Cell('Text')
     cell.append_text('Text', style_name='test')
     self.assertEqual(cell.value, 'TextText')
Beispiel #34
0
 def test_cover_cell(self):
     cell = Cell()
     cell._set_covered(True)
     self.assertTrue(cell.covered)
     self.assertEqual(cell.TAG, CoveredCell.TAG)
     self.assertEqual('Cell', cell.kind)
Beispiel #35
0
 def test_append_two_paragraphs(self):
     cell = Cell('test1')
     cell.append(Paragraph('test2'))
     self.assertEqual(cell.plaintext(), 'test1\ntest2')
     self.assertEqual(cell.value, 'test1\ntest2')
Beispiel #36
0
 def test_cover_cell_and_remove_unwanted_tags(self):
     cell = Cell()
     cell._set_span((2, 2))
     cell._set_covered(True)
     self.assertIsNone(cell.get_attr(CN('table:number-rows-spanned')))
     self.assertIsNone(cell.get_attr(CN('table:number-colums-spanned')))
Beispiel #37
0
 def test_append_text_error(self):
     cell = Cell(1.)
     with self.assertRaises(TypeError):
         cell.append_text('test')
Beispiel #38
0
 def test_has_xmlnode(self):
     cell = Cell()
     self.assertIsNotNone(cell.xmlnode)
Beispiel #39
0
 def test_set_float_without_type(self):
     cell = Cell()
     # set type explicit else type is string
     cell.set_value(100.)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.0)
Beispiel #40
0
 def test_get_style_name(self):
     cell = Cell()
     self.assertIsNone(cell.style_name)
Beispiel #41
0
 def test_set_true_boolean_with_type(self):
     cell = Cell()
     cell.set_value(True, 'boolean')
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, True)
Beispiel #42
0
 def test_set_style_name(self):
     cell = Cell()
     cell.style_name = 'STYLE'
     self.assertEqual(cell.style_name, 'STYLE')
     self.assertEqual(cell.get_attr(CN('table:style-name')), 'STYLE',
                      'wrong tag name')
Beispiel #43
0
 def test_set_currency(self):
     cell = Cell()
     cell.set_value(100., currency='EUR')
     self.assertEqual(cell.currency, 'EUR')
     self.assertEqual(cell.value_type, 'currency')
     self.assertEqual(cell.value, 100.)
Beispiel #44
0
 def test_get_content_validation_name(self):
     cell = Cell()
     self.assertIsNone(cell.content_validation_name)
Beispiel #45
0
 def test_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Beispiel #46
0
 def test_uncover_cell(self):
     cell = Cell()
     cell._set_covered(False)
     self.assertFalse(cell.covered)
     self.assertEqual(cell.TAG, Cell.TAG)
Beispiel #47
0
 def test_set_date_value(self):
     cell = Cell()
     cell.set_value('2011-01-29T12:00:00', 'date')
     self.assertEqual(cell.value_type, 'date')
     self.assertEqual(cell.value, '2011-01-29T12:00:00')
Beispiel #48
0
 def test_cover_cell_and_remove_unwanted_tags(self):
     cell = Cell()
     cell._set_span((2, 2))
     cell._set_covered(True)
     self.assertIsNone(cell.get_attr(CN('table:number-rows-spanned')))
     self.assertIsNone(cell.get_attr(CN('table:number-colums-spanned')))
Beispiel #49
0
 def test_init_type_without_value(self):
     cell = Cell(value_type='float')
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, None)
     self.assertEqual(cell.plaintext(), "")
Beispiel #50
0
 def test_has_TAG(self):
     cell = Cell()
     self.assertEqual(cell.TAG, CN('table:table-cell'))
Beispiel #51
0
 def test_cover_cell(self):
     cell = Cell()
     cell._set_covered(True)
     self.assertTrue(cell.covered)
     self.assertEqual(cell.TAG, CoveredCell.TAG)
     self.assertEqual('Cell', cell.kind)
Beispiel #52
0
 def test_error_display_form_for_string(self):
     cell = Cell('cell with string')
     with self.assertRaises(TypeError):
         cell.display_form = "raise Error"
Beispiel #53
0
 def test_set_style_name(self):
     cell = Cell()
     cell.style_name = 'STYLE'
     self.assertEqual(cell.style_name, 'STYLE')
     self.assertEqual(cell.get_attr(CN('table:style-name')), 'STYLE', 'wrong tag name')
Beispiel #54
0
 def test_set_protected(self):
     cell = Cell()
     cell.protected = True
     self.assertTrue(cell.protected)
Beispiel #55
0
 def test_setting_cell_by_address(self):
     self.table['A1'] = Cell('Textcell')
     cell = self.table[0, 0]
     self.assertEqual(cell.plaintext(), "Textcell")
Beispiel #56
0
 def test_set_span(self):
     cell = Cell()
     cell._set_span(( 2, 3) )
     self.assertEqual(cell.span, (2, 3))
Beispiel #57
0
 def test_set_cell_column_index_error(self):
     with self.assertRaises(IndexError):
         self.table[0, 10] = Cell()
Beispiel #58
0
 def test_check_valid_value_types(self):
     cell = Cell()
     for t in ('float', 'percentage', 'currency', 'date', 'time', 'boolean', 'string'):
         cell.set_value(1., t)
         self.assertEqual(cell.value_type, t)
Beispiel #59
0
 def test_set_cell_neg_column_index(self):
     self.table[0, -1] = Cell('Textcell')
     cell = self.table[0, 3]
     self.assertEqual(cell.plaintext(), "Textcell")
Beispiel #60
0
 def test_set_value_type(self):
     cell = Cell()
     cell.set_value('a string')
     self.assertEqual(cell.value_type, 'string')
     self.assertEqual(cell.get_attr(CN('office:value-type')), 'string',
                      'wrong tag name')