parent
336ef18eb8
commit
4fb5268acd
3 changed files with 52 additions and 19 deletions
|
|
@ -3,19 +3,20 @@ Unit tests for the prototypes and spawner
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from random import randint, sample
|
|
||||||
import mock
|
|
||||||
import uuid
|
import uuid
|
||||||
|
from random import randint, sample
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
|
import mock
|
||||||
from anything import Something
|
from anything import Something
|
||||||
from django.test.utils import override_settings
|
from django.test.utils import override_settings
|
||||||
|
from evennia.prototypes import menus as olc_menus
|
||||||
|
from evennia.prototypes import protfuncs as protofuncs
|
||||||
|
from evennia.prototypes import prototypes as protlib
|
||||||
|
from evennia.prototypes import spawner
|
||||||
|
from evennia.prototypes.prototypes import _PROTOTYPE_TAG_META_CATEGORY
|
||||||
from evennia.utils.test_resources import BaseEvenniaTest
|
from evennia.utils.test_resources import BaseEvenniaTest
|
||||||
from evennia.utils.tests.test_evmenu import TestEvMenu
|
from evennia.utils.tests.test_evmenu import TestEvMenu
|
||||||
from evennia.prototypes import spawner, prototypes as protlib
|
|
||||||
from evennia.prototypes import menus as olc_menus
|
|
||||||
from evennia.prototypes import protfuncs as protofuncs, spawner
|
|
||||||
|
|
||||||
from evennia.prototypes.prototypes import _PROTOTYPE_TAG_META_CATEGORY
|
|
||||||
|
|
||||||
_PROTPARENTS = {
|
_PROTPARENTS = {
|
||||||
"NOBODY": {},
|
"NOBODY": {},
|
||||||
|
|
@ -43,6 +44,11 @@ _PROTPARENTS = {
|
||||||
"key": "goblin archwizard",
|
"key": "goblin archwizard",
|
||||||
"prototype_parent": ("GOBLIN_WIZARD", "ARCHWIZARD"),
|
"prototype_parent": ("GOBLIN_WIZARD", "ARCHWIZARD"),
|
||||||
},
|
},
|
||||||
|
"ISSUE2908": {
|
||||||
|
"typeclass": "evennia.objects.objects.DefaultObject",
|
||||||
|
"key": "testobject_isse2909",
|
||||||
|
"location": "$choice($objlist(",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -163,10 +169,12 @@ class TestUtils(BaseEvenniaTest):
|
||||||
"key": "Obj",
|
"key": "Obj",
|
||||||
"home": Something,
|
"home": Something,
|
||||||
"location": Something,
|
"location": Something,
|
||||||
"locks": "call:true();control:perm(Developer);delete:perm(Admin);"
|
"locks": (
|
||||||
"drop:holds();"
|
"call:true();control:perm(Developer);delete:perm(Admin);"
|
||||||
"edit:perm(Admin);examine:perm(Builder);get:all();"
|
"drop:holds();"
|
||||||
"puppet:pperm(Developer);tell:perm(Admin);view:all()",
|
"edit:perm(Admin);examine:perm(Builder);get:all();"
|
||||||
|
"puppet:pperm(Developer);tell:perm(Admin);view:all()"
|
||||||
|
),
|
||||||
"prototype_desc": "Built from Obj",
|
"prototype_desc": "Built from Obj",
|
||||||
"prototype_key": Something,
|
"prototype_key": Something,
|
||||||
"prototype_locks": "spawn:all();edit:all()",
|
"prototype_locks": "spawn:all();edit:all()",
|
||||||
|
|
@ -183,10 +191,12 @@ class TestUtils(BaseEvenniaTest):
|
||||||
"home": Something,
|
"home": Something,
|
||||||
"key": "Obj",
|
"key": "Obj",
|
||||||
"location": Something,
|
"location": Something,
|
||||||
"locks": "call:true();control:perm(Developer);delete:perm(Admin);"
|
"locks": (
|
||||||
"drop:holds();"
|
"call:true();control:perm(Developer);delete:perm(Admin);"
|
||||||
"edit:perm(Admin);examine:perm(Builder);get:all();"
|
"drop:holds();"
|
||||||
"puppet:pperm(Developer);tell:perm(Admin);view:all()",
|
"edit:perm(Admin);examine:perm(Builder);get:all();"
|
||||||
|
"puppet:pperm(Developer);tell:perm(Admin);view:all()"
|
||||||
|
),
|
||||||
"new": "new_val",
|
"new": "new_val",
|
||||||
"permissions": ["Builder"],
|
"permissions": ["Builder"],
|
||||||
"prototype_desc": "New version of prototype",
|
"prototype_desc": "New version of prototype",
|
||||||
|
|
@ -962,3 +972,24 @@ class TestPartialTagAttributes(BaseEvenniaTest):
|
||||||
def test_partial_spawn(self):
|
def test_partial_spawn(self):
|
||||||
obj = spawner.spawn(self.prot)
|
obj = spawner.spawn(self.prot)
|
||||||
self.assertEqual(obj[0].key, self.prot["key"])
|
self.assertEqual(obj[0].key, self.prot["key"])
|
||||||
|
|
||||||
|
|
||||||
|
class TestIssue2908(BaseEvenniaTest):
|
||||||
|
"""
|
||||||
|
Test spawning a prototype with a nested protfunc, as per issue #2908.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
def test_spawn_with_protfunc(self):
|
||||||
|
|
||||||
|
self.room1.tags.add("beach", category="zone")
|
||||||
|
|
||||||
|
prot = {
|
||||||
|
"prototype_key": "rock",
|
||||||
|
"typeclass": "evennia.objects.objects.DefaultObject",
|
||||||
|
"key": "a rock",
|
||||||
|
"location": "$choice($objlist(beach,category=zone,type=tag))",
|
||||||
|
}
|
||||||
|
|
||||||
|
obj = spawner.spawn(prot, caller=self.char1)
|
||||||
|
self.assertEqual(obj[0].location, self.room1)
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,6 @@ class FuncParser:
|
||||||
|
|
||||||
if curr_func:
|
if curr_func:
|
||||||
# we are starting a nested funcdef
|
# we are starting a nested funcdef
|
||||||
# return_str = True
|
|
||||||
if len(callstack) > _MAX_NESTING:
|
if len(callstack) > _MAX_NESTING:
|
||||||
# stack full - ignore this function
|
# stack full - ignore this function
|
||||||
if raise_errors:
|
if raise_errors:
|
||||||
|
|
|
||||||
|
|
@ -788,9 +788,12 @@ class TestCallableSearch(test_resources.BaseEvenniaTest):
|
||||||
|
|
||||||
# get random result from the possible matches
|
# get random result from the possible matches
|
||||||
string = "$choice($objlist(beach,category=zone,type=tag))"
|
string = "$choice($objlist(beach,category=zone,type=tag))"
|
||||||
from evennia import set_trace
|
ret = parser.parse_to_any(string, caller=self.char1, raise_errors=True)
|
||||||
|
|
||||||
set_trace()
|
self.assertIn(ret, [self.obj1, self.obj2])
|
||||||
|
|
||||||
|
# test wrapping in $obj(), should just pass object through
|
||||||
|
string = "$obj($choice($objlist(beach,category=zone,type=tag)))"
|
||||||
ret = parser.parse_to_any(string, caller=self.char1, raise_errors=True)
|
ret = parser.parse_to_any(string, caller=self.char1, raise_errors=True)
|
||||||
|
|
||||||
self.assertIn(ret, [self.obj1, self.obj2])
|
self.assertIn(ret, [self.obj1, self.obj2])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue