mirror of
https://github.com/evennia/evennia.git
synced 2026-04-02 14:07:16 +02:00
Revamp _bad_recipe() helper function and fix @puzzle command empty name
This commit is contained in:
parent
921b354b9e
commit
8312d24600
3 changed files with 20 additions and 6 deletions
|
|
@ -118,6 +118,11 @@ class MuxCommand(Command):
|
|||
lhs, rhs = [arg.strip() for arg in args.split('=', 1)]
|
||||
lhslist = [arg.strip() for arg in lhs.split(',')]
|
||||
rhslist = [arg.strip() for arg in rhs.split(',')]
|
||||
# eliminate all empty-strings
|
||||
# if len(lhslist) > 0:
|
||||
# lhslist = list(filter(lambda i: len(i) > 0, lhslist))
|
||||
# if len(rhslist) > 0:
|
||||
# rhslist = list(filter(lambda i: len(i) > 0, rhslist))
|
||||
|
||||
# save to object properties:
|
||||
self.raw = raw
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ class CmdCreatePuzzleRecipe(MuxCommand):
|
|||
return
|
||||
|
||||
puzzle_name = self.lhslist[0]
|
||||
if len(puzzle_name) == 0:
|
||||
caller.msg('Invalid puzzle name %r.' % puzzle_name)
|
||||
return
|
||||
|
||||
def is_valid_obj_location(obj):
|
||||
valid = True
|
||||
|
|
|
|||
|
|
@ -1233,8 +1233,8 @@ class TestPuzzles(CommandTest):
|
|||
cmdstr,
|
||||
caller=self.char1
|
||||
)
|
||||
matches = self._assert_msg_matched(msg, regexs, re_flags=re.MULTILINE | re.DOTALL)
|
||||
recipe_dbref = self._assert_recipe(name, parts, results, and_destroy_it)
|
||||
matches = self._assert_msg_matched(msg, regexs, re_flags=re.MULTILINE | re.DOTALL)
|
||||
return recipe_dbref
|
||||
|
||||
def _arm(self, recipe_dbref, name, parts):
|
||||
|
|
@ -1272,7 +1272,7 @@ class TestPuzzles(CommandTest):
|
|||
_bad_syntax(',nothing')
|
||||
_bad_syntax('name, nothing')
|
||||
_bad_syntax('name, nothing =')
|
||||
# _bad_syntax(', = ,') # FIXME: got: Could not find ''.
|
||||
# _bad_syntax(', = ,') # FIXME: MuxCommand issue?
|
||||
|
||||
self._assert_no_recipes()
|
||||
|
||||
|
|
@ -1282,13 +1282,19 @@ class TestPuzzles(CommandTest):
|
|||
|
||||
# bad recipes
|
||||
def _bad_recipe(name, parts, results, fail_regex):
|
||||
with self.assertRaisesRegexp(AssertionError, fail_regex):
|
||||
self._good_recipe(name, parts, results)
|
||||
self.assert_no_recipes()
|
||||
cmdstr = ','.join([name] + parts) \
|
||||
+ '=' + ','.join(results)
|
||||
msg = self.call(
|
||||
puzzles.CmdCreatePuzzleRecipe(),
|
||||
cmdstr,
|
||||
caller=self.char1
|
||||
)
|
||||
self._assert_no_recipes()
|
||||
self.assertIsNotNone(re.match(fail_regex, msg), msg)
|
||||
|
||||
_bad_recipe('name', ['nothing'], ['neither'], r"Could not find 'nothing'.")
|
||||
_bad_recipe('name', ['stone'], ['nothing'], r"Could not find 'nothing'.")
|
||||
# _bad_recipe('', ['stone', 'fire'], ['stone', 'fire'], '') # FIXME: no name becomes '' #N(#N)
|
||||
_bad_recipe('', ['stone', 'fire'], ['stone', 'fire'], r"^Invalid puzzle name ''.")
|
||||
|
||||
self._assert_no_recipes()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue