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_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')
Example #4
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 #5
0
 def test_check_invalid_value_type(self):
     cell = Cell()
     with self.assertRaises(TypeError):
         cell.set_value('', value_type='invalid')
Example #6
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 #7
0
 def test_error_set_None_value(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(None)
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_int_without_type(self):
     cell = Cell()
     cell.set_value(100)
     self.assertEqual(cell.value_type, 'float')
     self.assertEqual(cell.value, 100.)
Example #10
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 #11
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 #12
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 #13
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 #14
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 #15
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 #16
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 #17
0
 def test_check_invalid_value_type(self):
     cell = Cell()
     with self.assertRaises(TypeError):
         cell.set_value('', value_type='invalid')
Example #18
0
 def test_error_set_None_value(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(None)
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_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Example #21
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 #22
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 #23
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 #24
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 #25
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 #26
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 #27
0
 def test_error_set_invalid_odf_object(self):
     cell = Cell()
     with self.assertRaises(ValueError):
         cell.set_value(GenericWrapper())
Example #28
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 #29
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 #30
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')