Merge pull request #2772 from avalonhope/develop

Adding unit tests for script search
This commit is contained in:
Griatch 2022-06-20 21:12:01 +02:00 committed by GitHub
commit ba2319c19f

View file

@ -0,0 +1,29 @@
from evennia.scripts.scripts import DefaultScript
from evennia.utils.test_resources import EvenniaTest
from evennia.utils.search import search_script_tag
class TestSearch(EvenniaTest):
def test_search_script_tag(self):
"""Check that a script can be found by its tag."""
script, errors = DefaultScript.create("a-script")
script.tags.add("a-tag")
found = search_script_tag("a-tag")
self.assertEqual(len(found), 1, errors)
self.assertEqual(script.key, found[0].key, errors)
def test_search_script_tag_category(self):
"""Check that a script can be found by its tag and category."""
script, errors = DefaultScript.create("a-script")
script.tags.add("a-tag", category="a-category")
found = search_script_tag("a-tag", category="a-category")
self.assertEqual(len(found), 1, errors)
self.assertEqual(script.key, found[0].key, errors)
def test_search_script_tag_wrong_category(self):
"""Check that a script can be found by its tag and category."""
script, errors = DefaultScript.create("a-script")
script.tags.add("a-tag", category="a-category")
found = search_script_tag("a-tag", category="wrong-category")
self.assertEqual(len(found), 0, errors)