mirror of
https://github.com/evennia/evennia.git
synced 2026-03-23 00:06:30 +01:00
Addition of TestBatchCommandProcessor.
This commit is contained in:
parent
14b23dc584
commit
31d3f92810
1 changed files with 39 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import codecs
|
|||
from django.test import TestCase
|
||||
from evennia.utils import batchprocessors, utils
|
||||
import mock
|
||||
import textwrap
|
||||
|
||||
|
||||
class TestBatchprocessorErrors(TestCase):
|
||||
|
|
@ -19,3 +20,41 @@ class TestBatchprocessorErrors(TestCase):
|
|||
def test_read_batchfile_raises_UnicodeDecodeError(self, *_):
|
||||
with self.assertRaises(UnicodeDecodeError, msg='decodeerr'):
|
||||
batchprocessors.read_batchfile('foopath')
|
||||
|
||||
|
||||
class TestBatchCommandProcessor(TestCase):
|
||||
|
||||
@mock.patch.object(batchprocessors, 'read_batchfile')
|
||||
def test_parses_2_commands(self, mocked_read):
|
||||
mocked_read.return_value = textwrap.dedent(
|
||||
r"""
|
||||
@create rock
|
||||
#
|
||||
|
||||
@set rock/desc =
|
||||
A big rock. You can tell is ancient.
|
||||
#
|
||||
|
||||
""")
|
||||
commands = batchprocessors.BATCHCMD.parse_file('foopath')
|
||||
self.assertEqual([
|
||||
'@create rock', '@set rock/desc =\nA big rock. You can tell is ancient.'],
|
||||
commands)
|
||||
|
||||
@mock.patch.object(batchprocessors, 'read_batchfile')
|
||||
def test_parses_INSERT(self, mocked_read):
|
||||
mocked_read.return_value = textwrap.dedent(
|
||||
r"""
|
||||
#INSERT another.ev
|
||||
#
|
||||
|
||||
""")
|
||||
mocked_read.return_value = textwrap.dedent(r"""
|
||||
@create bird
|
||||
#
|
||||
""")
|
||||
commands = batchprocessors.BATCHCMD.parse_file('foopath')
|
||||
self.assertEqual(
|
||||
['@create bird'],
|
||||
commands)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue