"""大纲解析：1.1 类编号不得被误拆成一级 1 与 title '.1 标题'。"""
import unittest

from modules.generator import _parse_outline


class TestParseOutline(unittest.TestCase):
    def test_11_stays_single_section(self):
        text = "某某项目标书标题\n1.1 沟槽开挖与支护\n1.2 排降水\n"
        _, sections, _ = _parse_outline(text)
        self.assertEqual(len(sections), 2, [s.get('number') for s in sections])
        for s in sections:
            if s.get('level') == 1:
                self.assertFalse(
                    (s.get('title') or '').lstrip().startswith('.'),
                    '不得出现一级章节 title 以 .1 开头（误将 1.1 拆成 1 与 .1 标题）',
                )
        titles = ' '.join(s['title'] for s in sections)
        self.assertIn('沟槽', titles)
        self.assertIn('排降', titles)


if __name__ == '__main__':
    unittest.main()
