Addition of TestBatchCommandProcessor.
This commit is contained in:
parent
903bf1663e
commit
de5073e916
1 changed files with 39 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import codecs
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from evennia.utils import batchprocessors, utils
|
from evennia.utils import batchprocessors, utils
|
||||||
import mock
|
import mock
|
||||||
|
import textwrap
|
||||||
|
|
||||||
|
|
||||||
class TestBatchprocessorErrors(TestCase):
|
class TestBatchprocessorErrors(TestCase):
|
||||||
|
|
@ -19,3 +20,41 @@ class TestBatchprocessorErrors(TestCase):
|
||||||
def test_read_batchfile_raises_UnicodeDecodeError(self, *_):
|
def test_read_batchfile_raises_UnicodeDecodeError(self, *_):
|
||||||
with self.assertRaises(UnicodeDecodeError, msg='decodeerr'):
|
with self.assertRaises(UnicodeDecodeError, msg='decodeerr'):
|
||||||
batchprocessors.read_batchfile('foopath')
|
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