Example #1
0
    def test_helpers(self):

        caller = self.caller

        # general helpers

        self.assertEqual(olc_menus._get_menu_prototype(caller), {})
        self.assertEqual(olc_menus._is_new_prototype(caller), True)

        self.assertEqual(olc_menus._set_menu_prototype(caller, {}), {})

        self.assertEqual(
            olc_menus._set_prototype_value(caller, "key", "TestKey"), {"key": "TestKey"}
        )
        self.assertEqual(olc_menus._get_menu_prototype(caller), {"key": "TestKey"})

        self.assertEqual(
            olc_menus._format_option_value(
                "key", required=True, prototype=olc_menus._get_menu_prototype(caller)
            ),
            " (TestKey|n)",
        )
        self.assertEqual(
            olc_menus._format_option_value([1, 2, 3, "foo"], required=True), " (1, 2, 3, foo|n)"
        )

        self.assertEqual(
            olc_menus._set_property(
                caller, "ChangedKey", prop="key", processor=str, next_node="foo"
            ),
            "foo",
        )
        self.assertEqual(olc_menus._get_menu_prototype(caller), {"key": "ChangedKey"})

        self.assertEqual(
            olc_menus._wizard_options("ThisNode", "PrevNode", "NextNode"),
            [
                {"goto": "node_PrevNode", "key": ("|wB|Wack", "b"), "desc": "|W(PrevNode)|n"},
                {"goto": "node_NextNode", "key": ("|wF|Worward", "f"), "desc": "|W(NextNode)|n"},
                {"goto": "node_index", "key": ("|wI|Wndex", "i")},
                {
                    "goto": ("node_validate_prototype", {"back": "ThisNode"}),
                    "key": ("|wV|Walidate prototype", "validate", "v"),
                },
            ],
        )

        self.assertEqual(olc_menus._validate_prototype(self.test_prot), (False, Something))
        self.assertEqual(
            olc_menus._validate_prototype({"prototype_key": "testthing", "key": "mytest"}),
            (True, Something),
        )

        choices = ["test1", "test2", "test3", "test4"]
        actions = (("examine", "e", "l"), ("add", "a"), ("foo", "f"))
        self.assertEqual(olc_menus._default_parse("l4", choices, *actions), ("test4", "examine"))
        self.assertEqual(olc_menus._default_parse("add 2", choices, *actions), ("test2", "add"))
        self.assertEqual(olc_menus._default_parse("foo3", choices, *actions), ("test3", "foo"))
        self.assertEqual(olc_menus._default_parse("f3", choices, *actions), ("test3", "foo"))
        self.assertEqual(olc_menus._default_parse("f5", choices, *actions), (None, None))
Example #2
0
    def test_node_helpers(self):

        caller = self.caller

        with mock.patch(
                "evennia.prototypes.menus.protlib.search_prototype",
                new=mock.MagicMock(return_value=[self.test_prot]),
        ):
            # prototype_key helpers
            self.assertEqual(
                olc_menus._check_prototype_key(caller, "test_prot"), None)
            caller.ndb._menutree.olc_new = True
            self.assertEqual(
                olc_menus._check_prototype_key(caller, "test_prot"),
                "node_index")

            # prototype_parent helpers
            self.assertEqual(olc_menus._all_prototype_parents(caller),
                             ["test_prot"])
            # self.assertEqual(olc_menus._prototype_parent_parse(
            #     caller, 'test_prot'),
            #     "|cprototype key:|n test_prot, |ctags:|n None, |clocks:|n edit:all();spawn:all() "
            #     "\n|cdesc:|n None \n|cprototype:|n "
            #     "{\n  'typeclass': 'evennia.objects.objects.DefaultObject', \n}")

        with mock.patch(
                "evennia.prototypes.menus.protlib.search_prototype",
                new=mock.MagicMock(return_value=[_PROTPARENTS["GOBLIN"]]),
        ):
            self.assertEqual(
                olc_menus._prototype_parent_select(caller, "goblin"),
                "node_prototype_parent")

        self.assertEqual(
            olc_menus._get_menu_prototype(caller),
            {
                "prototype_key": "test_prot",
                "prototype_locks": "edit:all();spawn:all()",
                "prototype_parent": "goblin",
                "typeclass": "evennia.objects.objects.DefaultObject",
            },
        )

        # typeclass helpers
        with mock.patch(
                "evennia.utils.utils.get_all_typeclasses",
                new=mock.MagicMock(return_value={
                    "foo": None,
                    "bar": None
                }),
        ):
            self.assertEqual(olc_menus._all_typeclasses(caller),
                             ["bar", "foo"])

        self.assertEqual(
            olc_menus._typeclass_select(
                caller, "evennia.objects.objects.DefaultObject"), None)
        # prototype_parent should be popped off here
        self.assertEqual(
            olc_menus._get_menu_prototype(caller),
            {
                "prototype_key": "test_prot",
                "prototype_locks": "edit:all();spawn:all()",
                "prototype_parent": "goblin",
                "typeclass": "evennia.objects.objects.DefaultObject",
            },
        )

        # attr helpers
        self.assertEqual(olc_menus._caller_attrs(caller), [])
        self.assertEqual(olc_menus._add_attr(caller, "test1=foo1"), Something)
        self.assertEqual(olc_menus._add_attr(caller, "test2;cat1=foo2"),
                         Something)
        self.assertEqual(
            olc_menus._add_attr(caller, "test3;cat2;edit:false()=foo3"),
            Something)
        self.assertEqual(
            olc_menus._add_attr(caller,
                                "test4;cat3;set:true();edit:false()=foo4"),
            Something)
        self.assertEqual(
            olc_menus._add_attr(caller,
                                "test5;cat4;set:true();edit:false()=123"),
            Something)
        self.assertEqual(olc_menus._add_attr(caller, "test1=foo1_changed"),
                         Something)
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["attrs"],
            [
                ("test1", "foo1_changed", None, ""),
                ("test2", "foo2", "cat1", ""),
                ("test3", "foo3", "cat2", "edit:false()"),
                ("test4", "foo4", "cat3", "set:true();edit:false()"),
                ("test5", "123", "cat4", "set:true();edit:false()"),
            ],
        )

        # tag helpers
        self.assertEqual(olc_menus._caller_tags(caller), [])
        self.assertEqual(olc_menus._add_tag(caller, "foo1"), Something)
        self.assertEqual(olc_menus._add_tag(caller, "foo2;cat1"), Something)
        self.assertEqual(olc_menus._add_tag(caller, "foo3;cat2;dat1"),
                         Something)
        self.assertEqual(olc_menus._caller_tags(caller),
                         ["foo1", "foo2", "foo3"])
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["tags"],
            [("foo1", None, ""), ("foo2", "cat1", ""),
             ("foo3", "cat2", "dat1")],
        )
        self.assertEqual(olc_menus._add_tag(caller, "foo1", delete=True),
                         "Removed Tag 'foo1'.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["tags"],
            [("foo2", "cat1", ""), ("foo3", "cat2", "dat1")],
        )

        self.assertEqual(
            olc_menus._display_tag(
                olc_menus._get_menu_prototype(caller)["tags"][0]), Something)
        self.assertEqual(olc_menus._caller_tags(caller), ["foo2", "foo3"])

        protlib.save_prototype(self.test_prot)

        # locks helpers
        self.assertEqual(olc_menus._lock_add(caller, "foo:false()"),
                         "Added lock 'foo:false()'.")
        self.assertEqual(olc_menus._lock_add(caller, "foo2:false()"),
                         "Added lock 'foo2:false()'.")
        self.assertEqual(olc_menus._lock_add(caller, "foo2:true()"),
                         "Lock with locktype 'foo2' updated.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["locks"],
            "foo:false();foo2:true()")

        # perm helpers
        self.assertEqual(olc_menus._add_perm(caller, "foo"),
                         "Added Permission 'foo'")
        self.assertEqual(olc_menus._add_perm(caller, "foo2"),
                         "Added Permission 'foo2'")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["permissions"],
            ["foo", "foo2"])

        # prototype_tags helpers
        self.assertEqual(olc_menus._add_prototype_tag(caller, "foo"),
                         "Added Prototype-Tag 'foo'.")
        self.assertEqual(olc_menus._add_prototype_tag(caller, "foo2"),
                         "Added Prototype-Tag 'foo2'.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["prototype_tags"],
            ["foo", "foo2"])

        # spawn helpers
        with mock.patch(
                "evennia.prototypes.menus.protlib.search_prototype",
                new=mock.MagicMock(return_value=[_PROTPARENTS["GOBLIN"]]),
        ):
            self.assertEqual(
                olc_menus._spawn(caller, prototype=self.test_prot), Something)
        obj = caller.contents[0]

        self.assertEqual(obj.typeclass_path,
                         "evennia.objects.objects.DefaultObject")
        self.assertEqual(obj.tags.get(category=spawner.PROTOTYPE_TAG_CATEGORY),
                         self.test_prot["prototype_key"])

        # update helpers
        self.assertEqual(
            olc_menus._apply_diff(caller,
                                  prototype=self.test_prot,
                                  back_node="foo",
                                  objects=[obj]),
            "foo",
        )  # no changes to apply
        self.test_prot["key"] = "updated key"  # change prototype
        self.assertEqual(
            olc_menus._apply_diff(caller,
                                  prototype=self.test_prot,
                                  objects=[obj],
                                  back_node="foo"),
            "foo",
        )  # apply change to the one obj

        # load helpers
        self.assertEqual(
            olc_menus._prototype_load_select(caller,
                                             self.test_prot["prototype_key"]),
            ("node_examine_entity", {
                "text": "|gLoaded prototype test_prot.|n",
                "back": "index"
            }),
        )

        # diff helpers
        obj_diff = {
            "attrs": {
                "desc": (
                    ("desc", "This is User #1.", None, ""),
                    ("desc", "This is User #1.", None, ""),
                    "KEEP",
                ),
                "foo": (None, ("foo", "bar", None, ""), "ADD"),
                "prelogout_location": (
                    ("prelogout_location", "#2", None, ""),
                    ("prelogout_location", "#2", None, ""),
                    "KEEP",
                ),
            },
            "home": ("#2", "#2", "KEEP"),
            "key": ("TestChar", "TestChar", "KEEP"),
            "locks": (
                "boot:false();call:false();control:perm(Developer);delete:false();"
                "edit:false();examine:perm(Developer);get:false();msg:all();"
                "puppet:false();tell:perm(Admin);view:all()",
                "boot:false();call:false();control:perm(Developer);delete:false();"
                "edit:false();examine:perm(Developer);get:false();msg:all();"
                "puppet:false();tell:perm(Admin);view:all()",
                "KEEP",
            ),
            "permissions": {
                "developer": ("developer", "developer", "KEEP")
            },
            "prototype_desc": ("Testobject build", None, "REMOVE"),
            "prototype_key": ("TestDiffKey", "TestDiffKey", "KEEP"),
            "prototype_locks":
            ("spawn:all();edit:all()", "spawn:all();edit:all()", "KEEP"),
            "prototype_tags": {},
            "tags": {
                "foo": (None, ("foo", None, ""), "ADD")
            },
            "typeclass": (
                "typeclasses.characters.Character",
                "typeclasses.characters.Character",
                "KEEP",
            ),
        }

        texts, options = olc_menus._format_diff_text_and_options(obj_diff)
        self.assertEqual(
            "\n".join(txt.strip() for txt in texts),
            "- |wattrs:|n    |c[1] |yADD|n: foo |W=|n bar |W(category:|n None|W, locks:|n |W)|n"
            "\n- |whome:|n"
            "\n- |wkey:|n"
            "\n- |wlocks:|n"
            "\n- |wpermissions:|n"
            "\n- |wprototype_desc:|n    |c[2] |rREMOVE|n: Testobject build"
            "\n- |wprototype_key:|n"
            "\n- |wprototype_locks:|n"
            "\n- |wprototype_tags:|n"
            "\n- |wtags:|n    |c[3] |yADD|n: foo |W(category:|n None|W)|n"
            "\n- |wtypeclass:|n",
        )

        self.assertEqual(
            options,
            [
                {
                    "goto": (Something, Something),
                    "key": "1",
                    "desc": "|gKEEP|n (attrs) None"
                },
                {
                    "goto": (Something, Something),
                    "key": "2",
                    "desc": "|gKEEP|n (prototype_desc) Testobject build",
                },
                {
                    "goto": (Something, Something),
                    "key": "3",
                    "desc": "|gKEEP|n (tags) None"
                },
            ],
        )
Example #3
0
    def test_node_helpers(self):

        caller = self.caller

        with mock.patch("evennia.prototypes.menus.protlib.search_prototype",
                        new=mock.MagicMock(return_value=[self.test_prot])):
            # prototype_key helpers
            self.assertEqual(
                olc_menus._check_prototype_key(caller, "test_prot"), None)
            caller.ndb._menutree.olc_new = True
            self.assertEqual(
                olc_menus._check_prototype_key(caller, "test_prot"),
                "node_index")

            # prototype_parent helpers
            self.assertEqual(olc_menus._all_prototype_parents(caller),
                             ['test_prot'])
            # self.assertEqual(olc_menus._prototype_parent_parse(
            #     caller, 'test_prot'),
            #     "|cprototype key:|n test_prot, |ctags:|n None, |clocks:|n edit:all();spawn:all() "
            #     "\n|cdesc:|n None \n|cprototype:|n "
            #     "{\n  'typeclass': 'evennia.objects.objects.DefaultObject', \n}")

        with mock.patch(
                "evennia.prototypes.menus.protlib.search_prototype",
                new=mock.MagicMock(return_value=[_PROTPARENTS['GOBLIN']])):
            self.assertEqual(
                olc_menus._prototype_parent_select(caller, "goblin"),
                "node_prototype_parent")

        self.assertEqual(
            olc_menus._get_menu_prototype(caller), {
                'prototype_key': 'test_prot',
                'prototype_locks': 'edit:all();spawn:all()',
                'prototype_parent': 'goblin',
                'typeclass': 'evennia.objects.objects.DefaultObject'
            })

        # typeclass helpers
        with mock.patch("evennia.utils.utils.get_all_typeclasses",
                        new=mock.MagicMock(return_value={
                            "foo": None,
                            "bar": None
                        })):
            self.assertEqual(olc_menus._all_typeclasses(caller),
                             ["bar", "foo"])

        self.assertEqual(
            olc_menus._typeclass_select(
                caller, "evennia.objects.objects.DefaultObject"), None)
        # prototype_parent should be popped off here
        self.assertEqual(
            olc_menus._get_menu_prototype(caller), {
                'prototype_key': 'test_prot',
                'prototype_locks': 'edit:all();spawn:all()',
                'prototype_parent': 'goblin',
                'typeclass': 'evennia.objects.objects.DefaultObject'
            })

        # attr helpers
        self.assertEqual(olc_menus._caller_attrs(caller), [])
        self.assertEqual(olc_menus._add_attr(caller, "test1=foo1"), Something)
        self.assertEqual(olc_menus._add_attr(caller, "test2;cat1=foo2"),
                         Something)
        self.assertEqual(
            olc_menus._add_attr(caller, "test3;cat2;edit:false()=foo3"),
            Something)
        self.assertEqual(
            olc_menus._add_attr(caller,
                                "test4;cat3;set:true();edit:false()=foo4"),
            Something)
        self.assertEqual(
            olc_menus._add_attr(caller,
                                "test5;cat4;set:true();edit:false()=123"),
            Something)
        self.assertEqual(olc_menus._add_attr(caller, "test1=foo1_changed"),
                         Something)
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)['attrs'],
            [("test1", "foo1_changed", None, ''),
             ("test2", "foo2", "cat1", ''),
             ("test3", "foo3", "cat2", "edit:false()"),
             ("test4", "foo4", "cat3", "set:true();edit:false()"),
             ("test5", '123', "cat4", "set:true();edit:false()")])

        # tag helpers
        self.assertEqual(olc_menus._caller_tags(caller), [])
        self.assertEqual(olc_menus._add_tag(caller, "foo1"), Something)
        self.assertEqual(olc_menus._add_tag(caller, "foo2;cat1"), Something)
        self.assertEqual(olc_menus._add_tag(caller, "foo3;cat2;dat1"),
                         Something)
        self.assertEqual(olc_menus._caller_tags(caller),
                         ['foo1', 'foo2', 'foo3'])
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)['tags'],
            [('foo1', None, ""), ('foo2', 'cat1', ""),
             ('foo3', 'cat2', "dat1")])
        self.assertEqual(olc_menus._add_tag(caller, "foo1", delete=True),
                         "Removed Tag 'foo1'.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)['tags'],
            [('foo2', 'cat1', ""), ('foo3', 'cat2', "dat1")])

        self.assertEqual(
            olc_menus._display_tag(
                olc_menus._get_menu_prototype(caller)['tags'][0]), Something)
        self.assertEqual(olc_menus._caller_tags(caller), ["foo2", "foo3"])

        protlib.save_prototype(**self.test_prot)

        # locks helpers
        self.assertEqual(olc_menus._lock_add(caller, "foo:false()"),
                         "Added lock 'foo:false()'.")
        self.assertEqual(olc_menus._lock_add(caller, "foo2:false()"),
                         "Added lock 'foo2:false()'.")
        self.assertEqual(olc_menus._lock_add(caller, "foo2:true()"),
                         "Lock with locktype 'foo2' updated.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["locks"],
            "foo:false();foo2:true()")

        # perm helpers
        self.assertEqual(olc_menus._add_perm(caller, "foo"),
                         "Added Permission 'foo'")
        self.assertEqual(olc_menus._add_perm(caller, "foo2"),
                         "Added Permission 'foo2'")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["permissions"],
            ["foo", "foo2"])

        # prototype_tags helpers
        self.assertEqual(olc_menus._add_prototype_tag(caller, "foo"),
                         "Added Prototype-Tag 'foo'.")
        self.assertEqual(olc_menus._add_prototype_tag(caller, "foo2"),
                         "Added Prototype-Tag 'foo2'.")
        self.assertEqual(
            olc_menus._get_menu_prototype(caller)["prototype_tags"],
            ["foo", "foo2"])

        # spawn helpers
        with mock.patch(
                "evennia.prototypes.menus.protlib.search_prototype",
                new=mock.MagicMock(return_value=[_PROTPARENTS['GOBLIN']])):
            self.assertEqual(
                olc_menus._spawn(caller, prototype=self.test_prot), Something)
        obj = caller.contents[0]

        self.assertEqual(obj.typeclass_path,
                         "evennia.objects.objects.DefaultObject")
        self.assertEqual(
            obj.tags.get(category=spawner._PROTOTYPE_TAG_CATEGORY),
            self.test_prot['prototype_key'])

        # update helpers
        self.assertEqual(
            olc_menus._apply_diff(caller,
                                  prototype=self.test_prot,
                                  back_node="foo",
                                  objects=[obj]), 'foo')  # no changes to apply
        self.test_prot['key'] = "updated key"  # change prototype
        self.assertEqual(
            olc_menus._apply_diff(caller,
                                  prototype=self.test_prot,
                                  objects=[obj],
                                  back_node='foo'),
            'foo')  # apply change to the one obj

        # load helpers
        self.assertEqual(
            olc_menus._prototype_load_select(caller,
                                             self.test_prot['prototype_key']),
            ('node_examine_entity', {
                'text': '|gLoaded prototype test_prot.|n',
                'back': 'index'
            }))

        # diff helpers
        obj_diff = {
            'attrs': {
                u'desc': ((u'desc', u'This is User #1.', None, ''),
                          (u'desc', u'This is User #1.', None, ''), 'KEEP'),
                u'foo': (None, (u'foo', u'bar', None, ''), 'ADD'),
                u'prelogout_location':
                ((u'prelogout_location', "#2", None, ''),
                 (u'prelogout_location', "#2", None, ''), 'KEEP')
            },
            'home': ('#2', '#2', 'KEEP'),
            'key': (u'TestChar', u'TestChar', 'KEEP'),
            'locks':
            ('boot:false();call:false();control:perm(Developer);delete:false();'
             'edit:false();examine:perm(Developer);get:false();msg:all();'
             'puppet:false();tell:perm(Admin);view:all()',
             'boot:false();call:false();control:perm(Developer);delete:false();'
             'edit:false();examine:perm(Developer);get:false();msg:all();'
             'puppet:false();tell:perm(Admin);view:all()', 'KEEP'),
            'permissions': {
                'developer': ('developer', 'developer', 'KEEP')
            },
            'prototype_desc': ('Testobject build', None, 'REMOVE'),
            'prototype_key': ('TestDiffKey', 'TestDiffKey', 'KEEP'),
            'prototype_locks':
            ('spawn:all();edit:all()', 'spawn:all();edit:all()', 'KEEP'),
            'prototype_tags': {},
            'tags': {
                'foo': (None, ('foo', None, ''), 'ADD')
            },
            'typeclass': (u'typeclasses.characters.Character',
                          u'typeclasses.characters.Character', 'KEEP')
        }

        texts, options = olc_menus._format_diff_text_and_options(obj_diff)
        self.assertEqual(
            "\n".join(texts), '- |wattrs:|n \n'
            '   |c[1] |yADD|n|W:|n None |W->|n foo |W=|n bar |W(category:|n None|W, locks:|n |W)|n\n'
            '   |gKEEP|W:|n prelogout_location |W=|n #2 |W(category:|n None|W, locks:|n |W)|n\n'
            '   |gKEEP|W:|n desc |W=|n This is User #1. |W(category:|n None|W, locks:|n |W)|n\n'
            '- |whome:|n    |gKEEP|W:|n #2\n'
            '- |wkey:|n    |gKEEP|W:|n TestChar\n'
            '- |wlocks:|n    |gKEEP|W:|n boot:false();call:false();control:perm(Developer);delete:false();edit:false();examine:perm(Developer);get:false();msg:all();puppet:false();tell:perm(Admin);view:all()\n'
            '- |wpermissions:|n \n'
            '   |gKEEP|W:|n developer\n'
            '- |wprototype_desc:|n    |c[2] |rREMOVE|n|W:|n Testobject build |W->|n None\n'
            '- |wprototype_key:|n    |gKEEP|W:|n TestDiffKey\n'
            '- |wprototype_locks:|n    |gKEEP|W:|n spawn:all();edit:all()\n'
            '- |wprototype_tags:|n \n'
            '- |wtags:|n \n'
            '   |c[3] |yADD|n|W:|n None |W->|n foo |W(category:|n None|W)|n\n'
            '- |wtypeclass:|n    |gKEEP|W:|n typeclasses.characters.Character')
        self.assertEqual(
            options, [{
                'goto': (Something, Something),
                'key': '1',
                'desc': '|gKEEP|n (attrs) None'
            }, {
                'goto': (Something, Something),
                'key': '2',
                'desc': '|gKEEP|n (prototype_desc) Testobject build'
            }, {
                'goto': (Something, Something),
                'key': '3',
                'desc': '|gKEEP|n (tags) None'
            }])
Example #4
0
    def test_helpers(self):

        caller = self.caller

        # general helpers

        self.assertEqual(olc_menus._get_menu_prototype(caller), {})
        self.assertEqual(olc_menus._is_new_prototype(caller), True)

        self.assertEqual(olc_menus._set_menu_prototype(caller, {}), {})

        self.assertEqual(
            olc_menus._set_prototype_value(caller, "key", "TestKey"),
            {"key": "TestKey"})
        self.assertEqual(olc_menus._get_menu_prototype(caller),
                         {"key": "TestKey"})

        self.assertEqual(
            olc_menus._format_option_value(
                "key",
                required=True,
                prototype=olc_menus._get_menu_prototype(caller)),
            " (TestKey|n)")
        self.assertEqual(
            olc_menus._format_option_value([1, 2, 3, "foo"], required=True),
            ' (1, 2, 3, foo|n)')

        self.assertEqual(
            olc_menus._set_property(caller,
                                    "ChangedKey",
                                    prop="key",
                                    processor=str,
                                    next_node="foo"), "foo")
        self.assertEqual(olc_menus._get_menu_prototype(caller),
                         {"key": "ChangedKey"})

        self.assertEqual(
            olc_menus._wizard_options("ThisNode", "PrevNode", "NextNode"),
            [{
                'goto': 'node_PrevNode',
                'key': ('|wB|Wack', 'b'),
                'desc': '|W(PrevNode)|n'
            }, {
                'goto': 'node_NextNode',
                'key': ('|wF|Worward', 'f'),
                'desc': '|W(NextNode)|n'
            }, {
                'goto': 'node_index',
                'key': ('|wI|Wndex', 'i')
            }, {
                'goto': ('node_validate_prototype', {
                    'back': 'ThisNode'
                }),
                'key': ('|wV|Walidate prototype', 'validate', 'v')
            }])

        self.assertEqual(olc_menus._validate_prototype(self.test_prot),
                         (False, Something))
        self.assertEqual(
            olc_menus._validate_prototype({
                "prototype_key": "testthing",
                "key": "mytest"
            }), (True, Something))

        choices = ["test1", "test2", "test3", "test4"]
        actions = (("examine", "e", "l"), ("add", "a"), ("foo", "f"))
        self.assertEqual(olc_menus._default_parse("l4", choices, *actions),
                         ('test4', 'examine'))
        self.assertEqual(olc_menus._default_parse("add 2", choices, *actions),
                         ('test2', 'add'))
        self.assertEqual(olc_menus._default_parse("foo3", choices, *actions),
                         ('test3', 'foo'))
        self.assertEqual(olc_menus._default_parse("f3", choices, *actions),
                         ('test3', 'foo'))
        self.assertEqual(olc_menus._default_parse("f5", choices, *actions),
                         (None, None))