mirror of
https://github.com/evennia/evennia.git
synced 2026-03-26 17:56:32 +01:00
Added unit tests for tree_select contrib
This commit is contained in:
parent
8b95b4718a
commit
2fcf1b3c04
1 changed files with 30 additions and 0 deletions
|
|
@ -1206,6 +1206,36 @@ class TestTurnBattleFunc(EvenniaTest):
|
|||
# Remove the script at the end
|
||||
turnhandler.stop()
|
||||
|
||||
# Test tree select
|
||||
|
||||
from evennia.contrib import tree_select
|
||||
|
||||
TREE_MENU_TESTSTR = """Foo
|
||||
Bar
|
||||
-Baz
|
||||
--Baz 1
|
||||
--Baz 2
|
||||
-Qux"""
|
||||
|
||||
class TestTreeSelectFunc(EvenniaTest):
|
||||
|
||||
def test_tree_functions(self):
|
||||
# Dash counter
|
||||
self.assertTrue(tree_select.dashcount("--test") == 2)
|
||||
# Is category
|
||||
self.assertTrue(tree_select.is_category(TREE_MENU_TESTSTR, 1) == True)
|
||||
# Parse options
|
||||
self.assertTrue(tree_select.parse_opts(TREE_MENU_TESTSTR, category_index=2) == [(3, "Baz 1"), (4, "Baz 2")])
|
||||
# Index to selection
|
||||
self.assertTrue(tree_select.index_to_selection(TREE_MENU_TESTSTR, 2) == "Baz")
|
||||
# Go up one category
|
||||
self.assertTrue(tree_select.go_up_one_category(TREE_MENU_TESTSTR, 4) == 2)
|
||||
# Option list to menu options
|
||||
test_optlist = tree_select.parse_opts(TREE_MENU_TESTSTR, category_index=2)
|
||||
optlist_to_menu_expected_result = [{'goto': ['menunode_treeselect', {'newindex': 3}], 'key': 'Baz 1'},
|
||||
{'goto': ['menunode_treeselect', {'newindex': 4}], 'key': 'Baz 2'},
|
||||
{'goto': ['menunode_treeselect', {'newindex': 1}], 'key': ['<< Go Back', 'go back', 'back'], 'desc': 'Return to the previous menu.'}]
|
||||
self.assertTrue(tree_select.optlist_to_menuoptions(TREE_MENU_TESTSTR, test_optlist, 2, True, True) == optlist_to_menu_expected_result)
|
||||
|
||||
# Test of the unixcommand module
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue