mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Merge pull request #2772 from avalonhope/develop
Adding unit tests for script search
This commit is contained in:
commit
ba2319c19f
1 changed files with 29 additions and 0 deletions
29
evennia/utils/tests/test_search.py
Normal file
29
evennia/utils/tests/test_search.py
Normal 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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue