def test_field_type_convert_to_string( self ): fs = StringFieldType() self.assertEqual( fs.getValue( BooleanFieldType().getValue( True ) ), 'True' ) self.assertEqual( fs.getValue( BooleanFieldType().getValue( False ) ), 'False' ) self.assertEqual( fs.getValue( DateFieldType().getValue( datetime.date( 2013, 2, 3 ) ) ), '2013-02-03' ) self.assertEqual( fs.getValue( DateTimeFieldType().getValue( datetime.datetime( 2013, 4, 4, 16, 06, 58, 929515 ) ) ), '2013-04-04 16:06:58.929515' ) self.assertEqual( fs.getValue( FloatFieldType().getValue( 4.232 ) ), '4.232' ) self.assertEqual( fs.getValue( IntegerFieldType().getValue( 5 ) ), '5' ) self.assertEqual( fs.getValue( StringFieldType().getValue('text') ), 'text' ) self.assertEqual( fs.getValue( TextFieldType().getValue('text') ), 'text' ) self.assertIsNone( fs.getValue( None ) )
def test_string_field_type( self ): ft = StringFieldType() self.assertEqual( ft.getValue('first of all'), 'first of all' ) self.assertEqual( ft.getValue(3), '3' ) self.assertEqual( ft.getValue(3.32), '3.32' ) self.assertEqual( ft.getValue( datetime.date.today() ), str( datetime.date.today() ) ) self.assertIsNone( ft.getValue( '' ) ) self.assertIsNone( ft.getValue( None ) )