Пример #1
0
 def test_data_access_non_existing_attribute(self):
     datas = MyDatas({"test_info": "test text"})
     document = Document(datas)
     section = document.new_section()
     text_class = TextClass(section)
     with pytest.raises(AttributeError):
         text_class.text = text_class.free_text(text_class.test_missing)
Пример #2
0
def iter_elem_with_post_treatment_fr(text_input, iter_const=None):
    datas = Datas({})
    doc = Document(datas, lang="fr")
    section = doc.new_section()
    section.text = section.tools.iter_elems(text_input, iter_const)
    section.write()
    return section.html.xpath('//div')[0].text_content()
Пример #3
0
 def test_data_access_attribute_with_text_class(self):
     datas = MyDatas({"test_info": "test text"})
     document = Document(datas)
     section = document.new_section()
     text_class = TextClass(section)
     text_class.text = text_class.free_text(text_class.test_info)
     assert str(text_class) == "test text"
Пример #4
0
def post_treatment_with_synonyms_fr(*text_input):
    datas = Datas({})
    doc = Document(datas, lang="fr")
    section = doc.new_section()
    section.text = section.tools.synonym(*text_input)
    section.write()
    return section.html.xpath('//div')[0].text_content()
Пример #5
0
def post_treatment_with_numbers_fr(num, **kwargs):
    datas = Datas({})
    doc = Document(datas, lang="fr")
    section = doc.new_section()
    section.text = section.tools.number(num, **kwargs)
    section.write()
    return section.html.xpath('//div')[0].text_content()
Пример #6
0
 def test_synonym_freeze(self, input):
     datas = Datas({})
     doc = Document(datas, lang="fr", freeze=True)
     section = doc.new_section()
     section.text = section.tools.nlg_syn(input)
     section.write()
     assert section.html.xpath('//div')[0].text_content() == input[0]
Пример #7
0
 def test_nested_synonym(self, input):
     datas = Datas({})
     doc = Document(datas, lang="fr")
     section = doc.new_section()
     section.text = section.tools.nlg_syn(section.tools.nlg_syn(input), section.tools.nlg_syn(input))
     section.write()
     assert section.html.xpath('//div')[0].text_content() in input
Пример #8
0
 def test_synonym_random(self, input):
     datas = Datas({})
     doc = Document(datas, lang="fr")
     section = doc.new_section()
     section.text = section.tools.synonym(input, mode="random")
     section.write()
     assert section.html.xpath('//div')[0].text_content() in input
Пример #9
0
 def test_keyval(self, input, expected):
     datas = Datas({})
     doc = Document(datas, lang="fr")
     section = doc.new_section()
     section.text = section.tools.nlg_syn(input)
     section.text = section.tools.post_eval("TEST_KEYVAL", "post", "")
     section.write()
     assert section.html.xpath('//div')[0].text_content() == expected
Пример #10
0
 def test_multi_synonym_keyval(self):
     datas = Datas({})
     doc = Document(datas, lang="fr")
     section = doc.new_section()
     syno1 = ("word", "TEST_1")
     syno2 = ("term", "TEST_2")
     section.text = section.tools.synonym(syno1, syno2)
     section.text = section.tools.post_eval("TEST_1",
                                            section.tools.synonym(syno2),
                                            section.tools.synonym(syno1))
     section.write()
     expected_result = ["Word term", "Term word"]
     assert section.html.xpath('//div')[0].text_content() in expected_result
Пример #11
0
 def test_multi_synonym(self):
     datas = Datas({})
     doc = Document(datas, lang="fr")
     section = doc.new_section()
     synos = ["word", "term", "note"]
     section.text = section.tools.synonym(synos)
     section.text = section.tools.synonym(synos)
     section.text = section.tools.synonym(synos)
     section.write()
     expected_output = [
         "Word term note", "Word note term", "Note word term",
         "Note term word", "Term word note", "Term note word"
     ]
     assert section.html.xpath('//div')[0].text_content() in expected_output
Пример #12
0
 def test_document_css(self):
     datas = Datas({})
     document = Document(datas, css_path="path/to/css")
     expected = "\n".join([
         '<html>',
         '<head>',
         '<meta charset="utf-8">',
         '<title></title>',
         '<link rel="stylesheet" href="path/to/css">',
         '</head>',
         '<body><div id="text_area"></div></body>',
         '</html>\n',
     ])
     assert str(document) == expected
Пример #13
0
def create_empty_section():
    datas = Datas({})
    document = Document(datas)
    return document, document.new_section()
Пример #14
0
def create_empty_doc():
    datas = Datas({})
    return Document(datas)
Пример #15
0
 def __init__(self, json_in):
     self.datas = MyDatas(json_in)
     self.document = Document(self.datas, lang="fr")
     self.intro = Intro(self.document)
     self.part_one = PartOne(self.document)