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