Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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')
Exemplo n.º 4
0
 def test_set_cell_row_index_error(self):
     with self.assertRaises(IndexError):
         self.table[10, 0] = Cell()
Exemplo n.º 5
0
 def test_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Exemplo n.º 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')
Exemplo n.º 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(), "")
Exemplo n.º 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.)
Exemplo n.º 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)
Exemplo n.º 10
0
 def test_constructor_with_style_name(self):
     cell = Cell(style_name='astyle')
     self.assertEqual('astyle', cell.style_name)
Exemplo n.º 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')
Exemplo n.º 12
0
 def test_float_no_type(self):
     cell = Cell(1.0)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 1.0)
Exemplo n.º 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)
Exemplo n.º 14
0
 def test_string(self):
     cell = Cell('text')
     self.assertEqual(cell.value_type, 'string')
     self.assertEqual(cell.value, 'text')
Exemplo n.º 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(), "")
Exemplo n.º 16
0
 def test_init_value_without_type(self):
     cell = Cell(value=100)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.)
Exemplo n.º 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')
Exemplo n.º 18
0
 def test_boolean_true(self):
     cell = Cell(True)
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, True)
Exemplo n.º 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)
Exemplo n.º 20
0
 def test_boolean_false(self):
     cell = Cell(False)
     self.assertEqual(cell.value_type, 'boolean')
     self.assertEqual(cell.value, False)
Exemplo n.º 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.)
Exemplo n.º 22
0
 def test_time_value(self):
     cell = Cell('PT0H05M00,0000S', 'time')
     self.assertEqual(cell.value_type, 'time')
     self.assertEqual(cell.value, 'PT0H05M00,0000S')
Exemplo n.º 23
0
 def test_error_set_None_value(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(None)
Exemplo n.º 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')
Exemplo n.º 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(), "")
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 28
0
 def test_Cell_is_kind_of_Cell(self):
     cell = Cell()
     covered_cell = Cell()
     self.assertEqual(covered_cell.kind, cell.kind)
Exemplo n.º 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")
Exemplo n.º 30
0
 def test_is_covered(self):
     cell = Cell()
     self.assertFalse(cell.covered)
Exemplo n.º 31
0
 def test_check_invalid_value_type(self):
     cell = Cell()
     with self.assertRaises(TypeError):
         cell.set_value('', value_type='invalid')
Exemplo n.º 32
0
 def test_uncover_cell(self):
     cell = Cell()
     cell._set_covered(False)
     self.assertFalse(cell.covered)
     self.assertEqual(cell.TAG, Cell.TAG)
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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')))
Exemplo n.º 37
0
 def test_append_text_error(self):
     cell = Cell(1.)
     with self.assertRaises(TypeError):
         cell.append_text('test')
Exemplo n.º 38
0
 def test_has_xmlnode(self):
     cell = Cell()
     self.assertIsNotNone(cell.xmlnode)
Exemplo n.º 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)
Exemplo n.º 40
0
 def test_get_style_name(self):
     cell = Cell()
     self.assertIsNone(cell.style_name)
Exemplo n.º 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)
Exemplo n.º 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')
Exemplo n.º 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.)
Exemplo n.º 44
0
 def test_get_content_validation_name(self):
     cell = Cell()
     self.assertIsNone(cell.content_validation_name)
Exemplo n.º 45
0
 def test_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Exemplo n.º 46
0
 def test_uncover_cell(self):
     cell = Cell()
     cell._set_covered(False)
     self.assertFalse(cell.covered)
     self.assertEqual(cell.TAG, Cell.TAG)
Exemplo n.º 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')
Exemplo n.º 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')))
Exemplo n.º 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(), "")
Exemplo n.º 50
0
 def test_has_TAG(self):
     cell = Cell()
     self.assertEqual(cell.TAG, CN('table:table-cell'))
Exemplo n.º 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)
Exemplo n.º 52
0
 def test_error_display_form_for_string(self):
     cell = Cell('cell with string')
     with self.assertRaises(TypeError):
         cell.display_form = "raise Error"
Exemplo n.º 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')
Exemplo n.º 54
0
 def test_set_protected(self):
     cell = Cell()
     cell.protected = True
     self.assertTrue(cell.protected)
Exemplo n.º 55
0
 def test_setting_cell_by_address(self):
     self.table['A1'] = Cell('Textcell')
     cell = self.table[0, 0]
     self.assertEqual(cell.plaintext(), "Textcell")
Exemplo n.º 56
0
 def test_set_span(self):
     cell = Cell()
     cell._set_span(( 2, 3) )
     self.assertEqual(cell.span, (2, 3))
Exemplo n.º 57
0
 def test_set_cell_column_index_error(self):
     with self.assertRaises(IndexError):
         self.table[0, 10] = Cell()
Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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')