mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Implementation
This commit is contained in:
@@ -1,41 +1,39 @@
|
||||
import unittest
|
||||
|
||||
from ptulsconv.transformations import TagInterpreter
|
||||
|
||||
from ptulsconv.docparser.tagged_string_parser_visitor import parse_tags, TagPreModes
|
||||
|
||||
|
||||
class TestTagInterpreter(unittest.TestCase):
|
||||
def test_line(self):
|
||||
ti = TagInterpreter()
|
||||
s1 = ti.parse_tags("this is a test")
|
||||
s1 = parse_tags("this is a test")
|
||||
self.assertEqual(s1.content, "this is a test")
|
||||
self.assertEqual(s1.mode, 'Normal')
|
||||
self.assertEqual(s1.mode, TagPreModes.NORMAL)
|
||||
self.assertEqual(len(s1.tag_dict), 0)
|
||||
|
||||
s2 = ti.parse_tags("this! IS! Me! ** Typing! 123 <> |||")
|
||||
s2 = parse_tags("this! IS! Me! ** Typing! 123 <> |||")
|
||||
self.assertEqual(s2.content, "this! IS! Me! ** Typing! 123 <> |||")
|
||||
self.assertEqual(s2.mode, 'Normal')
|
||||
self.assertEqual(s2.mode, TagPreModes.NORMAL)
|
||||
self.assertEqual(len(s2.tag_dict), 0)
|
||||
|
||||
def test_tags(self):
|
||||
ti = TagInterpreter()
|
||||
s1 = ti.parse_tags("{a=100}")
|
||||
s1 = parse_tags("{a=100}")
|
||||
self.assertEqual(s1.tag_dict['a'], "100")
|
||||
|
||||
s2 = ti.parse_tags("{b=This is a test} [option] $X=9")
|
||||
s2 = parse_tags("{b=This is a test} [option] $X=9")
|
||||
self.assertEqual(s2.tag_dict['b'], 'This is a test')
|
||||
self.assertEqual(s2.tag_dict['option'], 'option')
|
||||
self.assertEqual(s2.tag_dict['X'], "9")
|
||||
|
||||
def test_modes(self):
|
||||
ti = TagInterpreter()
|
||||
s1 = ti.parse_tags("@ Monday Tuesday {a=1}")
|
||||
self.assertEqual(s1.mode, 'Timespan')
|
||||
s1 = parse_tags("@ Monday Tuesday {a=1}")
|
||||
self.assertEqual(s1.mode, TagPreModes.TIMESPAN)
|
||||
|
||||
s2 = ti.parse_tags("Monday Tuesday {a=1}")
|
||||
self.assertEqual(s2.mode, 'Normal')
|
||||
s2 = parse_tags("Monday Tuesday {a=1}")
|
||||
self.assertEqual(s2.mode, TagPreModes.NORMAL)
|
||||
|
||||
s3 = ti.parse_tags("&Monday Tuesday {a=1}")
|
||||
self.assertEqual(s3.mode, 'Append')
|
||||
s3 = parse_tags("&Monday Tuesday {a=1}")
|
||||
self.assertEqual(s3.mode, TagPreModes.APPEND)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -3,7 +3,6 @@ import unittest
|
||||
import ptulsconv.docparser.tag_compiler
|
||||
from ptulsconv.docparser import doc_entity
|
||||
from fractions import Fraction
|
||||
import pprint
|
||||
|
||||
|
||||
class TestTagCompiler(unittest.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user