diff --git a/evennia/utils/tests/test_batchprocessors.py b/evennia/utils/tests/test_batchprocessors.py index 84acb623e2..4b9c34fe2f 100644 --- a/evennia/utils/tests/test_batchprocessors.py +++ b/evennia/utils/tests/test_batchprocessors.py @@ -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) +