def test_novel_serialized(self):
     scode0 = SCode(None, SCmd.BE, (), '')
     scode1 = SCode(None, SCmd.INFO_DATA, (), '')
     data = [
         # (src, expect)
         (True, Chapter('a', Episode('b', Scene('c', scode0))), 1),
         (True, Chapter('a', scode1, Episode('b', Scene('c', scode0))), 2),
     ]
     validate_with_fail(
         self, 'novel_serialized', lambda src, expect: self.assertEqual(
             len(sl.Serializer()._novel_serialized(src)), expect), data)
Ejemplo n.º 2
0
 def test_scenes_of(self):
     data = [
         # (src, expect[int])
         (True, Story('a', Chapter('b', Episode('c', Scene('d', )))), 1),
         (True, Chapter('a', Episode('b', Scene('c', ))), 1),
         (True, Episode('a', Scene('b', )), 1),
         (True, Scene('a', ), 1),
         (True, SCode(None, SCmd.BE, (), ''), 0),
     ]
     validate_with_fail(
         self, 'scenes_of', lambda src, expect: self.assertEqual(
             cnt.Counter().scenes_of(src), expect), data)
Ejemplo n.º 3
0
 def test_scodes_of_without_info(self):
     scode0 = SCode(None, SCmd.BE, (), '')
     sinfo = SCode(None, SCmd.INFO_DATA, (), '')
     data = [
         # (src, expect[int])
         (True,
          Story('a', Chapter('b', Episode('c', Scene('d', scode0,
                                                     sinfo)))), 1),
         (True, Chapter('a', Episode('b', Scene('c', scode0, sinfo))), 1),
         (True, Episode('a', Scene('b', scode0, sinfo)), 1),
         (True, Scene('a', scode0, sinfo), 1),
         (True, scode0, 1),
         (True, sinfo, 0),
     ]
     validate_with_fail(
         self, 'scode_of_without_info',
         lambda src, expect: self.assertEqual(
             cnt.Counter().scodes_of_without_info(src), expect), data)
Ejemplo n.º 4
0
 def test_description_characters_of(self):
     scode0 = SCode(None, SCmd.BE, ('apple', ), '')
     scode1 = SCode(None, SCmd.DO, ('orange', ), '')
     sinfo = SCode(None, SCmd.INFO_DATA, ('test', ), '')
     data = [
         # (src, expect[int])
         (True,
          Story(
              'a',
              Chapter('b', Episode('c', Scene('d', scode0, scode1,
                                              sinfo)))), 13),
         (True, Chapter('a', Episode('b', Scene('c', scode0, scode1,
                                                sinfo))), 13),
         (True, Episode('a', Scene('b', scode0, scode1, sinfo)), 13),
         (True, Scene('a', scode0, scode1, sinfo), 13),
         (True, scode0, 6),
         (True, sinfo, 0),
         (True, [scode0, scode1], 13),
     ]
     validate_with_fail(
         self, 'description_characters_of',
         lambda src, expect: self.assertEqual(
             cnt.Counter().description_characters_of(src), expect), data)
Ejemplo n.º 5
0
 def test_manupaper_rows_of(self):
     scode0 = SCode(None, SCmd.BE, ('apple', ), '')
     scode1 = SCode(None, SCmd.DO, ('orange', ), '')
     scode2 = SCode(None, SCmd.TALK, ('melon', ), '')
     data = [
         # (src, columns, expect[int])
         (True,
          Story(
              'a',
              Chapter('b', Episode('c', Scene('d', scode0, scode1,
                                              scode2)))), 20, 3),
         (True,
          Chapter('a', Episode('b', Scene('c', scode0, scode1,
                                          scode2))), 20, 3),
         (True, Episode('a', Scene('b', scode0, scode1, scode2)), 20, 3),
         (True, Scene('a', scode0, scode1, scode2), 20, 3),
         (True, scode0, 20, 1),
         (True, [scode0, scode1, scode2], 20, 3),
         (True, SCode(None, SCmd.DO, ('a' * 10, )), 5, 3),
     ]
     validate_with_fail(
         self, 'manupaper_rows_of',
         lambda src, columns, expect: self.assertEqual(
             cnt.Counter().manupaper_rows_of(src, columns), expect), data)
Ejemplo n.º 6
0
 def scene(self, *args, **kwargs) -> Scene:
     ''' Create a scene container and set contents.
     '''
     return Scene(*args, **kwargs)