Example #1
0
    def test_LongField_validates_long_values_correctly(self):
        field = LongField()

        try:
            field.validate(100000000000L)
        except ValidationError:
            self.fail('LongField.validate() raised ValidationError unexpectedly')
Example #2
0
    def test_LongField_validates_with_min_and_max_values(self):
        field = LongField(min=41L, max=43L)

        try:
            field.validate(41L)
            field.validate(43L)
        except ValidationError:
            self.fail('LongField.validate() raised ValidationError unexpectedly')

        self.assertRaises(ValidationError, field.validate, 40L)
        self.assertRaises(ValidationError, field.validate, 44L)
Example #3
0
    def test_LongField_validates_long_values_correctly(self):
        field = LongField()

        try:
            field.validate(100000000000L)
        except ValidationError:
            self.fail(
                'LongField.validate() raised ValidationError unexpectedly')
Example #4
0
    def test_LongField_validates_with_min_and_max_values(self):
        field = LongField(min=41L, max=43L)

        try:
            field.validate(41L)
            field.validate(43L)
        except ValidationError:
            self.fail(
                'LongField.validate() raised ValidationError unexpectedly')

        self.assertRaises(ValidationError, field.validate, 40L)
        self.assertRaises(ValidationError, field.validate, 44L)
Example #5
0
    def test_LongField_json_methods(self):
        f = LongField()

        self.assertEquals(1234567890L, f.from_json(f.to_json(1234567890L)))
        self.assertEquals(1234567890, f.to_json(f.from_json(1234567890L)))
Example #6
0
 def test_LongField_validates_None_if_value_can_be_None(self):
     field = LongField(can_be_none=True)
     field.validate(None)
Example #7
0
 def test_LongField_validates_None_if_value_can_be_None(self):
     field = LongField(can_be_none=True)
     field.validate(None)
Example #8
0
    def test_LongField_raises_ValidationError_on_incorrect_types(self):
        field = LongField()

        self.assertRaises(ValidationError, field.validate, 42)
        self.assertRaises(ValidationError, field.validate, None)
Example #9
0
    def test_LongField_json_methods(self):
        f = LongField()

        self.assertEquals(1234567890L, f.from_json(f.to_json(1234567890L)))
        self.assertEquals(1234567890, f.to_json(f.from_json(1234567890L)))