Addition of TestBatchCommandProcessor.

This commit is contained in:
Henddher Pedroza 2019-10-13 16:59:28 -04:00
parent 14b23dc584
commit 31d3f92810

View file

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