Exemple #1
0
    def test_gather_errors(self):
        def raiser(): raise appier.OperationalError(message = "hello")
        struct = appier.lazy_dict(
            first = appier.lazy(lambda: raiser()),
            second = appier.lazy(lambda: 2),
        )

        errors = appier.gather_errors(struct)
        self.assertEqual(errors, dict(first = ["hello"]))

        struct.__getitem__("first", force = True)._value = 1

        errors = appier.gather_errors(struct)
        self.assertEqual(errors, dict(first = ["hello"]))

        struct.__getitem__("first", force = True)._value = 1

        errors = appier.gather_errors(struct, resolve = False)
        self.assertEqual(errors, dict())
Exemple #2
0
    def test_gather_errors(self):
        def raiser(): raise appier.OperationalError(message = "hello")
        struct = appier.lazy_dict(
            first = appier.lazy(lambda: raiser()),
            second = appier.lazy(lambda: 2),
        )

        errors = appier.gather_errors(struct)
        self.assertEqual(errors, dict(first = ["hello"]))

        struct.__getitem__("first", force = True)._value = 1

        errors = appier.gather_errors(struct)
        self.assertEqual(errors, dict(first = ["hello"]))

        struct.__getitem__("first", force = True)._value = 1

        errors = appier.gather_errors(struct, resolve = False)
        self.assertEqual(errors, dict())