示例#1
0
    def check_call(self, context, call_factory, exp_name):
        call = call_factory("toto")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "toto", (), {}))

        call = call_factory("toto", "egg")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "toto", ("egg",), {}))

        call = call_factory("toto", bacon="spam")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "toto", (), {"bacon": "spam"}))

        call = call_factory("toto", 1, 2, 3, bacon="spam", egg=2)
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "toto", (1, 2, 3), {"bacon": "spam", "egg": 2}))

        call = call_factory("toto")
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "toto", (), {}))

        call = call_factory("toto", "egg")
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "toto", ("egg",), {}))

        call = call_factory("toto", bacon="spam")
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "toto", (), {"bacon": "spam"}))

        call = call_factory("toto", 1, 2, 3, bacon="spam", egg=2)
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "toto", (1, 2, 3), {"bacon": "spam", "egg": 2}))
示例#2
0
    def check_perform(self, context, call_factory, exp_name):
        call = call_factory("tata")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "tata", (), {"value": None}))

        call = call_factory("tata", "egg")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "tata", ("egg",), {"value": None}))

        call = call_factory("tata", bacon="spam")
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "tata", (), {"value": None, "bacon": "spam"}))

        call = call_factory("tata", 1, 2, 3, bacon="spam", egg=2)
        res = yield call(None, context)
        self.assertEqual(res, (exp_name, "tata", (1, 2, 3), {"value": None, "bacon": "spam", "egg": 2}))

        call = call_factory("tata")
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "tata", (), {"value": "spam", "foo": "bar"}))

        call = call_factory("tata", "egg")
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "tata", ("egg",), {"value": "spam", "foo": "bar"}))

        call = call_factory("tata", bacon="spam")
        res = yield call("spam", context, foo="bar", bar="foo")
        self.assertEqual(res, (exp_name, "tata", (), {"value": "spam", "bacon": "spam", "foo": "bar", "bar": "foo"}))

        call = call_factory("tata", 1, 2, 3, bacon="spam", egg=2)
        res = yield call("spam", context, foo="bar")
        self.assertEqual(res, (exp_name, "tata", (1, 2, 3), {"value": "spam", "bacon": "spam", "egg": 2, "foo": "bar"}))

        call = call_factory("tata", 1, 2, 3, bacon="spam", egg=2)
        res = yield call("spam", context, foo="bar", egg=42)
        self.assertEqual(
            res, (exp_name, "tata", (1, 2, 3), {"value": "spam", "bacon": "spam", "egg": 42, "foo": "bar"})
        )