diff --git a/evennia/utils/tests/test_search.py b/evennia/utils/tests/test_search.py index 6bacfb4cb3..63515d6754 100644 --- a/evennia/utils/tests/test_search.py +++ b/evennia/utils/tests/test_search.py @@ -1,6 +1,6 @@ from evennia.scripts.scripts import DefaultScript from evennia.utils.test_resources import EvenniaTest -from evennia.utils.search import search_script_tag +from evennia.utils.search import search_script_attribute, search_script_tag class TestSearch(EvenniaTest): @@ -21,9 +21,30 @@ class TestSearch(EvenniaTest): 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.""" + """Check that a script cannot be found by the wrong 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) - + + def test_search_script_tag_wrong(self): + """Check that a script cannot be found by the wrong tag.""" + script, errors = DefaultScript.create("a-script") + script.tags.add("a-tag", category="a-category") + found = search_script_tag("wrong-tag", category="a-category") + self.assertEqual(len(found), 0, errors) + + def test_search_script_attribute(self): + """Check that a script can be found by its attributes.""" + script, errors = DefaultScript.create("a-script") + script.db.an_attribute = "some value" + found = search_script_attribute(key="an_attribute", value="some value") + self.assertEqual(len(found), 1, errors) + self.assertEqual(script.key, found[0].key, errors) + + def test_search_script_attribute_wrong(self): + """Check that a script cannot be found by wrong value of its attributes.""" + script, errors = DefaultScript.create("a-script") + script.db.an_attribute = "some value" + found = search_script_attribute(key="an_attribute", value="wrong value") + self.assertEqual(len(found), 0, errors)