mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
rewrite new test for clarity
This commit is contained in:
parent
f8de9a484e
commit
c41f5d9ebd
2 changed files with 19 additions and 11 deletions
|
|
@ -1352,7 +1352,9 @@ class ContribRPObject(DefaultObject):
|
|||
results.extend(
|
||||
[
|
||||
obj
|
||||
for obj in search_obj(searched_obj.key, candidates=[searched_obj], **kwargs)
|
||||
for obj in search_obj(
|
||||
searched_obj.key, candidates=[searched_obj], **kwargs
|
||||
)
|
||||
if obj not in results
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -352,31 +352,37 @@ class TestRPSystem(BaseEvenniaTest):
|
|||
self.obj2 = create_object(rpsystem.ContribRPCharacter, key="Obj2", location=self.room)
|
||||
self.obj2.sdesc.add("something")
|
||||
candidates = [self.obj1, self.obj2]
|
||||
|
||||
# search candidates by sdesc: both objects should be found
|
||||
result = self.speaker.get_search_result("something", candidates)
|
||||
self.assertIn(self.obj1, result)
|
||||
self.assertIn(self.obj2, result)
|
||||
self.assertEqual(list(result), candidates)
|
||||
|
||||
# search by sdesc with 2-disambiguator: only second object should be found
|
||||
result = self.speaker.get_search_result("2-something", candidates)
|
||||
self.assertNotIn(self.obj1, result)
|
||||
self.assertIn(self.obj2, result)
|
||||
self.assertEqual(list(result), [self.obj2])
|
||||
|
||||
# search empty candidates: no objects should be found
|
||||
result = self.speaker.get_search_result("something", candidates=[])
|
||||
self.assertNotIn(self.obj1, result)
|
||||
self.assertNotIn(self.obj2, result)
|
||||
self.assertEqual(list(result), [])
|
||||
|
||||
# typeclass was given: only matching object should be found
|
||||
result = self.speaker.get_search_result(
|
||||
"something", candidates=candidates, typeclass=rpsystem.ContribRPCharacter
|
||||
)
|
||||
self.assertNotIn(self.obj1, result)
|
||||
self.assertIn(self.obj2, result)
|
||||
self.assertEqual(list(result), [self.obj2])
|
||||
|
||||
# search by key with player permissions: no objects should be found
|
||||
result = self.speaker.get_search_result("obj1", candidates)
|
||||
self.assertNotIn(self.obj1, result)
|
||||
self.assertEqual(list(result), [])
|
||||
|
||||
# search by key with builder permissions: object should be found
|
||||
self.speaker.permissions.add("builder")
|
||||
result = self.speaker.get_search_result("obj1", candidates)
|
||||
self.assertIn(self.obj1, result)
|
||||
self.assertEqual(list(result), [self.obj1])
|
||||
|
||||
# search by key with builder permissions when NOT IN candidates: object should NOT be found
|
||||
result = self.speaker.get_search_result("obj1", [self.obj2])
|
||||
self.assertEqual(list(result), [])
|
||||
|
||||
|
||||
class TestRPSystemCommands(BaseEvenniaCommandTest):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue