def test_normalize_types_should_convert_types_correctly(self): table = Table(headers=["spam", "eggs", "ham", "Monty", "Python"]) table.append(["1", "2.71", "2011-01-01", "2011-01-01 02:03:04", "asd"]) table.append([None, None, None, None, None]) table.append([None, None, None, None, 42]) table.normalize_types() self.assertEquals(table[0][0], 1) self.assertEquals(table[0][1], 2.71) self.assertEquals(table[0][2], datetime.date(2011, 1, 1)) self.assertEquals(table[0][3], datetime.datetime(2011, 1, 1, 2, 3, 4)) self.assertEquals(table[0][4], "asd")
def test_running_identify_data_type_with_normalized_types_should_return_correct_results(self): table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python']) table.append([1, 2.71, '2011-01-01', '2011-01-01 00:00:00', 'asd']) table.append(['', '', '', '', '']) table.normalize_types() table._identify_type_of_data() self.assertEquals(table.types['spam'], int) self.assertEquals(table.types['eggs'], float) self.assertEquals(table.types['ham'], datetime.date) self.assertEquals(table.types['Monty'], datetime.datetime) self.assertEquals(table.types['Python'], str)
def test_normalize_types_should_convert_types_correctly(self): table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python']) table.append(['1', '2.71', '2011-01-01', '2011-01-01 02:03:04', 'asd']) table.append([None, None, None, None, None]) table.append([None, None, None, None, 42]) table.normalize_types() self.assertEquals(table[0][0], 1) self.assertEquals(table[0][1], 2.71) self.assertEquals(table[0][2], datetime.date(2011, 1, 1)) self.assertEquals(table[0][3], datetime.datetime(2011, 1, 1, 2, 3, 4)) self.assertEquals(table[0][4], 'asd')
def test_running_identify_data_type_with_normalized_types_should_return_correct_results( self): table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python']) table.append([1, 2.71, '2011-01-01', '2011-01-01 00:00:00', 'asd']) table.append(['', '', '', '', '']) table.normalize_types() table._identify_type_of_data() self.assertEquals(table.types['spam'], int) self.assertEquals(table.types['eggs'], float) self.assertEquals(table.types['ham'], datetime.date) self.assertEquals(table.types['Monty'], datetime.datetime) self.assertEquals(table.types['Python'], str)
def test_normalize_types_should_convert_types_correctly(self): table = Table(headers=['spam', 'eggs', 'ham', 'Monty', 'Python']) table.append(['1', '2.71', '2011-01-01', '2011-01-01 02:03:04', 'asd']) table.append([None, None, None, None, None]) table.append([None, None, None, None, 42]) table.normalize_types() self.assertEquals(table[0][0], 1) self.assertEquals(table[0][1], 2.71) self.assertEquals(table[0][2], datetime.date(2011, 1, 1)) self.assertEquals(table[0][3], datetime.datetime(2011, 1, 1, 2, 3, 4)) self.assertEquals(table[0][4], 'asd')