示例#1
0
 def test_structure_parser_with_nested_h4(self):
     wiki = """
     = Titel =
     einleitungstext
     ==== slot1 ====
     text
     ==== Toller Slot § slot2 ====
     mehr text
     """
     schema = {'short_title': "foo",
               'title': "Titel",
               'text': "einleitungstext",
               'children': [
                   {'short_title': "slot1",
                    'title': "slot1",
                    'text': "text",
                    'children': []},
                   {'short_title': "slot2",
                    'title': "Toller Slot",
                    'text': "mehr text",
                    'children': []},
               ]}
     s = self.parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     self.assertEqual(s, schema)
 def test_structure_parser_with_nested_h4(self):
     wiki = """
     = Titel =
     einleitungstext
     ==== slot1 ====
     text
     ==== Toller Slot § slot2 ====
     mehr text
     """
     schema = {
         'short_title':
         "foo",
         'title':
         "Titel",
         'text':
         "einleitungstext",
         'children': [
             {
                 'short_title': "slot1",
                 'title': "slot1",
                 'text': "text",
                 'children': []
             },
             {
                 'short_title': "slot2",
                 'title': "Toller Slot",
                 'text': "mehr text",
                 'children': []
             },
         ]
     }
     s = self.parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     self.assertEqual(s, schema)
示例#3
0
 def test_structure_parser_with_deep_example(self):
     wiki = """
     = Titel =
     text
     == Titel1 § slot1 ==
     text1
     === Titel11 § slot11 ===
     text11
     ==== Titel111 § slot111 ===
     text111
     === Titel12 § slot12 ===
     text12
     == Titel2 § slot2 ==
     text2
     === Titel21 § slot21 ===
     text21
     === Titel22 § slot22 ===
     text22
     ==== Titel221 § slot221 ===
     text221
     """
     schema = {'title': "Titel", 'short_title': "foo", 'text': "text",
               'children': [
                   {'title': "Titel1", 'short_title': "slot1",
                    'text': "text1",
                    'children': [
                        {'title': "Titel11", 'short_title': "slot11",
                         'text': "text11",
                         'children': [
                             {'title': "Titel111", 'short_title': "slot111",
                              'text': "text111",
                              'children': []}
                         ]},
                        {'title': "Titel12", 'short_title': "slot12",
                         'text': "text12",
                         'children': []},
                    ]},
                   {'title': "Titel2", 'short_title': "slot2",
                    'text': "text2",
                    'children': [
                        {'title': "Titel21", 'short_title': "slot21",
                         'text': "text21",
                         'children': []},
                        {'title': "Titel22", 'short_title': "slot22",
                         'text': "text22",
                         'children': [
                             {'title': "Titel221", 'short_title': "slot221",
                              'text': "text221",
                              'children': []}
                         ]},
                    ]},
               ]}
     for pname, parse in self.parser.items():
         s = parse(wiki, "foo")
         self.assertTrue(validate_structure_schema(s), "fail in " + pname)
         print(s)
         print(schema)
         self.assertEqual(s, schema, "fail in " + pname)
    def test_structure_parser_with_single_node_example(self):
        wiki = """=Titel=
        Der text."""
        schema = {
            'short_title': "foo",
            'title': "Titel",
            'text': "Der text.",
            'children': []
        }

        s = self.parse(wiki, "foo")
        self.assertTrue(validate_structure_schema(s))
        self.assertEqual(s, schema)
示例#5
0
    def test_structure_parser_with_single_node_example(self):
        wiki = """=Titel=
        Der text."""
        schema = {
            'short_title': "foo",
            'title': "Titel",
            'text': "Der text.",
            'children': []
        }

        s = self.parse(wiki, "foo")
        self.assertTrue(validate_structure_schema(s))
        self.assertEqual(s, schema)
示例#6
0
 def test_structure_parser_with_single_node_example(self):
     wiki = """=Titel=
     Der text."""
     schema = {
         'short_title': "foo",
         'title': "Titel",
         'text': "Der text.",
         'children': []
     }
     for pname, parse in self.parser.items():
         s = parse(wiki, "foo")
         self.assertTrue(validate_structure_schema(s), "fail in " + pname)
         self.assertEqual(s, schema, "fail in " + pname)
 def test_structure_parser_short_title_in_h1_is_silently_removed(self):
     wiki = """
     = Titel § removed =
     Der text.
     """
     schema = {
         'short_title': "foo",
         'title': "Titel",
         'text': "Der text.",
         'children': []
     }
     s = self.parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     self.assertEqual(s, schema)
示例#8
0
 def test_structure_parser_short_title_in_h1_is_silently_removed(self):
     wiki = """
     = Titel § removed =
     Der text.
     """
     schema = {
         'short_title': "foo",
         'title': "Titel",
         'text': "Der text.",
         'children': []
     }
     s = self.parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     self.assertEqual(s, schema)
示例#9
0
 def test_structure_parser_short_title_in_h1_is_silently_removed(self):
     wiki = """
     = Titel § removed =
     Der text.
     """
     schema = {
         'short_title': "foo",
         'title': "Titel",
         'text': "Der text.",
         'children': []
     }
     for pname, parse in self.parser.items():
         s = parse(wiki, "foo")
         self.assertTrue(validate_structure_schema(s), "fail in " + pname)
         self.assertEqual(s, schema, "fail in " + pname)
示例#10
0
    def test_structure_parser_processes_short_title(self):
        wiki = """=Titel=
        == Slot § shört, title!#$|~ ==
        """
        schema = {
            'short_title': "foo", 'title': "Titel", 'text': "",
            'children': [
                {'short_title': "shoert_title", 'title': "Slot", 'text': "",
                 'children': []
                 }
            ]
        }

        s = self.parse(wiki, "foo")
        self.assertTrue(validate_structure_schema(s))
        self.assertEqual(s, schema)
示例#11
0
 def test_structure_parser_processes_short_title(self):
     wiki = """=Titel=
     == Slot § shört, title!#$|~ ==
     """
     schema = {
         'short_title': "foo", 'title': "Titel", 'text': "",
         'children': [
             {'short_title': "shoert_title", 'title': "Slot", 'text': "",
              'children': []
              }
         ]
     }
     for pname, parse in self.parser.items():
         s = parse(wiki, "foo")
         self.assertTrue(validate_structure_schema(s), "fail in " + pname)
         self.assertEqual(s, schema, "fail in " + pname)
示例#12
0
    def test_structure_parser_processes_short_title(self):
        wiki = """=Titel=
        == Slot § shört, title!#$|~ ==
        """
        schema = {
            'short_title':
            "foo",
            'title':
            "Titel",
            'text':
            "",
            'children': [{
                'short_title': "shoert_title",
                'title': "Slot",
                'text': "",
                'children': []
            }]
        }

        s = self.parse(wiki, "foo")
        self.assertTrue(validate_structure_schema(s))
        self.assertEqual(s, schema)
示例#13
0
 def test_structure_parser(self):
     wiki = """
     = Titel =
     einleitungstext
     == slot1 ==
     text
     == Toller Slot § slot2 ==
     mehr text
     """
     s = parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     schema = {'short_title': "foo",
               'title': "Titel",
               'text': "einleitungstext",
               'children': [
                   {'short_title': "slot1",
                    'title': "slot1",
                    'text': "text",
                    'children': []},
                   {'short_title': "slot2",
                    'title': "Toller Slot",
                    'text': "mehr text",
                    'children': []},
                   ]}
     self.assertEqual(s,schema)
     wiki = """
     = Titel =
     einleitungstext
     === slot1 ===
     text
     == Toller Slot § slot2 ==
     mehr text
     """
     self.assertRaises(InvalidWikiStructure,parse,wiki,"foo")
     wiki = "== Titel =="
     self.assertRaises(InvalidWikiStructure,parse,wiki,"foo")
示例#14
0
 def test_structure_parser_with_deep_example(self):
     wiki = """
     = Titel =
     text
     == Titel1 § slot1 ==
     text1
     === Titel11 § slot11 ===
     text11
     ==== Titel111 § slot111 ===
     text111
     === Titel12 § slot12 ===
     text12
     == Titel2 § slot2 ==
     text2
     === Titel21 § slot21 ===
     text21
     === Titel22 § slot22 ===
     text22
     ==== Titel221 § slot221 ===
     text221
     """
     schema = {
         'title':
         "Titel",
         'short_title':
         "foo",
         'text':
         "text",
         'children': [
             {
                 'title':
                 "Titel1",
                 'short_title':
                 "slot1",
                 'text':
                 "text1",
                 'children': [
                     {
                         'title':
                         "Titel11",
                         'short_title':
                         "slot11",
                         'text':
                         "text11",
                         'children': [{
                             'title': "Titel111",
                             'short_title': "slot111",
                             'text': "text111",
                             'children': []
                         }]
                     },
                     {
                         'title': "Titel12",
                         'short_title': "slot12",
                         'text': "text12",
                         'children': []
                     },
                 ]
             },
             {
                 'title':
                 "Titel2",
                 'short_title':
                 "slot2",
                 'text':
                 "text2",
                 'children': [
                     {
                         'title': "Titel21",
                         'short_title': "slot21",
                         'text': "text21",
                         'children': []
                     },
                     {
                         'title':
                         "Titel22",
                         'short_title':
                         "slot22",
                         'text':
                         "text22",
                         'children': [{
                             'title': "Titel221",
                             'short_title': "slot221",
                             'text': "text221",
                             'children': []
                         }]
                     },
                 ]
             },
         ]
     }
     s = self.parse(wiki, "foo")
     self.assertTrue(validate_structure_schema(s))
     self.assertEqual(s, schema)
示例#15
0
 def test_validate_structure_schema_on_simple_example_with_slot(self):
     simple = dict(title="foo",
                   short_title="foo",
                   text="und bar und so",
                   children=[])
     self.assertTrue(validate_structure_schema(simple))
示例#16
0
 def test_validate_structure_schema_on_simple_example_with_slot(self):
     simple = dict(title="foo", short_title="foo", text="und bar und so",
                   children=[])
     self.assertTrue(validate_structure_schema(simple))