コード例 #1
0
 def test_from_cdms_value_None_without_nullable_field(self):
     """
     When null=False, None values are returned as empty strings.
     """
     field = StringField('name', null=False)
     self.assertEqual(
         field.from_cdms_value(None),
         ''
     )
コード例 #2
0
 def test_from_cdms_value_None_with_nullable_field(self):
     """
     When null=True, None values are returned untouched.
     """
     field = StringField('name', null=True)
     self.assertEqual(
         field.from_cdms_value(None),
         None
     )
コード例 #3
0
class StringFieldTestCase(TestCase):
    def setUp(self):
        super(StringFieldTestCase, self).setUp()
        self.field = StringField('name')

    def test_from_cdms_value(self):
        self.assertEqual(
            self.field.from_cdms_value('a string'),
            'a string'
        )

    def test_from_cdms_value_None_with_nullable_field(self):
        """
        When null=True, None values are returned untouched.
        """
        field = StringField('name', null=True)
        self.assertEqual(
            field.from_cdms_value(None),
            None
        )

    def test_from_cdms_value_None_without_nullable_field(self):
        """
        When null=False, None values are returned as empty strings.
        """
        field = StringField('name', null=False)
        self.assertEqual(
            field.from_cdms_value(None),
            ''
        )

    def test_to_cdms_value(self):
        self.assertEqual(
            self.field.to_cdms_value('a string'),
            'a string'
        )

    def test_to_cdms_value_None(self):
        self.assertEqual(
            self.field.to_cdms_value(None),
            None
        )
コード例 #4
0
 def setUp(self):
     super(StringFieldTestCase, self).setUp()
     self.field = StringField('name')