コード例 #1
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_method(self):
        """
        Tests the add_method method with a name
        """

        dispatcher = Dispatcher()
        dispatcher.add_method(func1, name="test")

        self.assertDictEqual({"test": func1}, dispatcher.method_handlers, "Method map was not updated properly")
コード例 #2
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_construct_method_map_dict(self):
        """
        Tests that the construct_method_map works with a dict
        """

        dispatcher = Dispatcher()
        dispatcher.construct_method_map(METHOD_MAP)

        self.assertDictEqual(METHOD_MAP, dispatcher.method_handlers, "Method map was not constructed properly")
コード例 #3
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_dict(self):
        """
        Tests the add_dict method
        """

        dispatcher = Dispatcher()
        dispatcher.add_dict(METHOD_MAP)

        self.assertDictEqual(METHOD_MAP, dispatcher.method_handlers, "Method map was not updated properly")
コード例 #4
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_method_non_coroutine(self):
        """
        Tests that the add_method method doesn't accept regular functions
        """

        def _i_fail():
            pass

        dispatcher = Dispatcher()
        dispatcher.add_method(_i_fail)
コード例 #5
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_dict_prefix(self):
        """
        Tests the add_dict method with a prefix
        """

        method_map = {("prefix." + k): v for k, v in METHOD_MAP.items()}
        dispatcher = Dispatcher()
        dispatcher.add_dict(METHOD_MAP, prefix="prefix")

        self.assertDictEqual(method_map, dispatcher.method_handlers, "Method map was not updated properly")
コード例 #6
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_constr_method_map_prefix(self):
        """
        Tests that the construct_method_map works with a prefix
        """

        dispatcher = Dispatcher()
        dispatcher.construct_method_map(METHOD_MAP, prefix="prefix.")

        method_map = {("prefix." + k): v for k, v in METHOD_MAP.items()}

        self.assertDictEqual(method_map, dispatcher.method_handlers, "Method map was not constructed properly")
コード例 #7
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_construct_method_map_class(self):
        """
        Tests that the construct_method_map works with a class
        """

        dispatcher = Dispatcher()
        dispatcher.construct_method_map(MethodMapClass)

        self.assertDictEqual(
            {"test1": MethodMapClass.test1, "test2": MethodMapClass.test2},
            dispatcher.method_handlers,
            "Method map was not constructed properly",
        )
コード例 #8
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_class(self):
        """
        Tests the add_class method
        """

        dispatcher = Dispatcher()
        dispatcher.add_class(MethodMapClass)

        self.assertDictEqual(
            {"methodmapclass.test1": MethodMapClass.test1, "methodmapclass.test2": MethodMapClass.test2},
            dispatcher.method_handlers,
            "Method map was not updated properly",
        )
コード例 #9
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_construct_method_map_obj(self):
        """
        Tests that the construct_method_map works with an object
        """

        method_map = MethodMapObject()
        dispatcher = Dispatcher()
        dispatcher.construct_method_map(method_map)

        self.assertDictEqual(
            {"test1": method_map.test1, "test2": method_map.test2},
            dispatcher.method_handlers,
            "Method map was not constructed properly",
        )
コード例 #10
0
ファイル: test_dispatcher.py プロジェクト: durandj/mymcadmin
    def test_add_object(self):
        """
        Tests the add_object method
        """

        method_map = MethodMapObject()
        dispatcher = Dispatcher()
        dispatcher.add_object(method_map)

        self.assertDictEqual(
            {"methodmapobject.test1": method_map.test1, "methodmapobject.test2": method_map.test2},
            dispatcher.method_handlers,
            "Method map was not updated properly",
        )