Example #1
0
    def test_add_law_action(self):
        text = '第二条に次の二項を加え'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, AddLawAction))
        self.assertEqual(Query.from_text('第二条'), action.at)
        self.assertEqual('二項', action.what)
        self.assertTrue(is_serializable(action))
Example #2
0
 def test_chapter(self):
     fp = './resource/chapter.xml'
     chapter = parse_xml(ET.parse(fp).getroot())
     self.assertTrue(isinstance(chapter, Chapter))
     self.assertEqual('第一章 総則', chapter.title)
     self.assertEqual(0, len(chapter.children))
     self.assertEqual('第一章 総則\n', str(chapter))
     self.assertTrue(is_serializable(chapter))
Example #3
0
    def test_rename_action(self):
        text = '一条中第三項を第四項とする'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, RenameAction))
        self.assertEqual(Query.from_text('一条中第三項'), action.old)
        self.assertEqual(Query.from_text('第四項'), action.new)
        self.assertTrue(is_serializable(action))
Example #4
0
 def test_item(self):
     fp = './resource/item.xml'
     item = parse_xml(ET.parse(fp).getroot())
     self.assertEqual('第一号', item.title)
     self.assertEqual('ほどほどに頑張ること。', item.sentence)
     self.assertEqual(0, len(item.children))
     self.assertEqual(INDENT + '一' + SPACE + 'ほどほどに頑張ること。', str(item))
     self.assertTrue(is_serializable(item))
Example #5
0
    def test_replace_action_short(self):
        text = '「第百二十五条」を「第百二十五条の二」に'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, ReplaceAction))
        self.assertEqual(Query.from_text(''), action.at)
        self.assertEqual('第百二十五条', action.old)
        self.assertEqual('第百二十五条の二', action.new)
        self.assertTrue(is_serializable(action))
Example #6
0
    def test_replace_action(self):
        text = '第一条中「中「小」」を「大「中」」に改める'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, ReplaceAction))
        self.assertEqual(Query.from_text('第一条'), action.at)
        self.assertEqual('中「小」', action.old)
        self.assertEqual('大「中」', action.new)
        self.assertTrue(is_serializable(action))
Example #7
0
    def test_add_word_action_short(self):
        text = '「前項」の下に「について」を'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, AddWordAction))
        self.assertEqual(Query.from_text(''), action.at)
        self.assertEqual('前項', action.word)
        self.assertEqual('について', action.what)
        self.assertTrue(is_serializable(action))
Example #8
0
 def test_paragraph(self):
     fp = './resource/paragraph.xml'
     paragraph = parse_xml(ET.parse(fp).getroot())
     self.assertTrue(isinstance(paragraph, Paragraph))
     self.assertEqual(1, paragraph.number)
     self.assertEqual('第一項', paragraph.title)
     self.assertEqual('本文ただし書', paragraph.sentence)
     self.assertEqual(0, len(paragraph.children))
     self.assertTrue(is_serializable(paragraph))
Example #9
0
    def test_delete_action_short(self):
        text = '「その他」及び「前項」を削り'
        action = parse_action_text(text)

        self.assertTrue(isinstance(action, DeleteAction))
        self.assertEqual(Query.from_text(''), action.at)
        self.assertEqual(2, len(action.whats))
        self.assertEqual('その他', action.whats[0])
        self.assertEqual('前項', action.whats[1])
        self.assertTrue(is_serializable(action))
Example #10
0
 def test_article(self):
     fp = './resource/article.xml'
     article = parse_xml(ET.parse(fp).getroot())
     self.assertTrue(isinstance(article, Article))
     self.assertEqual('(登記簿等の持出禁止)', article.caption)
     self.assertEqual('第七条の二', article.title)
     self.assertEqual('7_2', article.number)
     self.assertEqual(0, len(article.children))
     self.assertEqual('(登記簿等の持出禁止)\n第七条の二\n', str(article))
     self.assertTrue(is_serializable(article))
Example #11
0
    def test_from_text(self):
        text = '第一条第二項第三号の次'
        query = Query.from_text(text)

        self.assertEqual(text, query.text)
        self.assertEqual(QueryType.AFTER, query.query_type)
        self.assertEqual('第一条', query.get(LawHierarchy.ARTICLE))
        self.assertEqual('第二項', query.get(LawHierarchy.PARAGRAPH))
        self.assertEqual('第三号', query.get(LawHierarchy.ITEM))
        self.assertEqual('', query.get(LawHierarchy.SUBITEM1))
        self.assertTrue(is_serializable(query))
        print(query.serialize())
Example #12
0
 def test_parse_xml(self):
     fp = './resource/law.xml'
     for node in ET.parse(fp).getroot():
         tree = parse_xml(node)
         self.assertTrue(is_serializable(tree))