Update test_search.py

This commit is contained in:
Avalon Hope 2022-07-08 11:16:06 +01:00 committed by GitHub
parent 5814883949
commit 7887ad487b

View file

@ -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)