Merge branch 'develop' into contrib/evadventure

This commit is contained in:
Griatch 2022-07-11 11:24:46 +02:00
commit 83395211cc
32 changed files with 1766 additions and 34 deletions

View file

@ -1,6 +1,6 @@
from evennia.scripts.scripts import DefaultScript
from evennia.utils.test_resources import EvenniaTest
from evennia.utils.search import search_script_attribute, search_script_tag
from evennia.utils.search import search_script_attribute, search_script_tag, search_script
class TestSearch(EvenniaTest):
@ -48,3 +48,17 @@ class TestSearch(EvenniaTest):
script.db.an_attribute = "some value"
found = search_script_attribute(key="an_attribute", value="wrong value")
self.assertEqual(len(found), 0, errors)
def test_search_script_key(self):
"""Check that a script can be found by its key value."""
script, errors = DefaultScript.create("a-script")
found = search_script("a-script")
self.assertEqual(len(found), 1, errors)
self.assertEqual(script.key, found[0].key, errors)
def test_search_script_wrong_key(self):
"""Check that a script cannot be found by a wrong key value."""
script, errors = DefaultScript.create("a-script")
found = search_script("wrong_key")
self.assertEqual(len(found), 0, errors)

View file

@ -57,21 +57,30 @@ class TestDedent(TestCase):
class TestListToString(TestCase):
"""
Default function header from utils.py:
list_to_string(inlist, endsep="and", addquote=False)
list_to_string(inlist, sep=",", endsep=", and", addquote=False)
Examples:
no endsep:
with defaults:
[1,2,3] -> '1, 2, and 3'
with endsep==',':
[1,2,3] -> '1, 2, 3'
with sep==';' and endsep==';':
[1,2,3] -> '1; 2; 3'
with endsep=='and':
[1,2,3] -> '1, 2 and 3'
with addquote and endsep
with endsep=='':
[1,2,3] -> '1, 2 3'
with addquote and endsep="and"
[1,2,3] -> '"1", "2" and "3"'
"""
def test_list_to_string(self):
self.assertEqual("1, 2, 3", utils.list_to_string([1, 2, 3], endsep=""))
self.assertEqual('"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep="", addquote=True))
self.assertEqual("1, 2, and 3", utils.list_to_string([1, 2, 3]))
self.assertEqual("1, 2, 3", utils.list_to_string([1, 2, 3], endsep=","))
self.assertEqual("1, 2 and 3", utils.list_to_string([1, 2, 3], endsep="and"))
self.assertEqual("1, 2 3", utils.list_to_string([1, 2, 3], endsep=""))
self.assertEqual("1; 2; 3", utils.list_to_string([1, 2, 3], sep=";", endsep=";"))
self.assertEqual('"1", "2", "3"', utils.list_to_string([1, 2, 3], endsep=",", addquote=True))
self.assertEqual(
'"1", "2" and "3"', utils.list_to_string([1, 2, 3], endsep="and", addquote=True)
)