示例#1
0
    def test_eq_number(self):
        methods = [quorum.eq("age", 2)]

        object = dict(age=2)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertTrue(result)

        object = dict(age=2.0)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertTrue(result)

        object = dict(age=3)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(age="2")
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(age=2.01)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)
示例#2
0
    def test_eq_string(self):
        methods = [quorum.eq("name", "John Doe")]

        object = dict(name = "John Doe")
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertTrue(result)

        object = dict(name = "john doe")
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(name = "JohnDoe")
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(name = 2)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(name = 2.0)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(name = True)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)
示例#3
0
    def test_eq_number(self):
        methods = [quorum.eq("age", 2)]

        object = dict(age = 2)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertTrue(result)

        object = dict(age = 2.0)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertTrue(result)

        object = dict(age = 3)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(age = "2")
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)

        object = dict(age = 2.01)
        result = quorum.validation.validate_b(
            methods = methods,
            object = object,
            build = False
        )
        self.assertFalse(result)
示例#4
0
    def test_eq_string(self):
        methods = [quorum.eq("name", "John Doe")]

        object = dict(name="John Doe")
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertTrue(result)

        object = dict(name="john doe")
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(name="JohnDoe")
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(name=2)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(name=2.0)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)

        object = dict(name=True)
        result = quorum.validation.validate_b(methods=methods,
                                              object=object,
                                              build=False)
        self.assertFalse(result)