def test_translation_by_key(self): db_add_objects(Word, words) db_add_objects(Type, types) db_add_objects(Author, authors) db_add_objects(Key, keys) db_add_objects(Definition, definitions) db_add_objects(Event, all_events) db_connect_authors(connect_authors) db_connect_words(connect_words) db_connect_keys(connect_keys) expected_result_ultra = """<ld><wn>pru</wn>, <de>(af) a combining form of <l>pruci</l>, <k>test</k>.</de></ld> <ld><wn>pruci</wn>, <de>[V‍-‍BF] (3n) V is a <k>test</k>/examination for property B in any member of class F.</de></ld> <ld><wn>pruci</wn>, <de>(vt) <k>test</k>, test for … a property … in a member of ….</de></ld> <ld><wn>prukao</wn>, <o><test act></o> <de>[K‍-‍BPV] (4v) K <k>test</k>/examine B for P with test V.</de></ld> <ld><wn>po prukao</wn>, <o><test act></o> <de>(n) a <k>test</k>/examination, an act of testing.</de></ld>""" result = Word.translation_by_key("test") assert result == expected_result_ultra expected_result_normal = """<div class="d_line"><span class="w_name">pru</span>, <span class="definition eng" id=13521><span class="dg">(af)</span> <span class="db">a combining form of <l>pruci</l>, <k>test</k>.</span></span></div> <div class="d_line"><span class="w_name">pruci</span>, <span class="definition eng" id=13523><span class="dt">[V‍-‍BF]</span> <span class="dg">(3n)</span> <span class="db">V is a <k>test</k>/examination for property B in any member of class F.</span></span></div> <div class="d_line"><span class="w_name">pruci</span>, <span class="definition eng" id=13524><span class="dg">(vt)</span> <span class="db"><k>test</k>, test for … a property … in a member of ….</span></span></div> <div class="d_line"><span class="w_name">prukao</span>, <span class="w_origin"><test act></span> <span class="definition eng" id=13527><span class="dt">[K‍-‍BPV]</span> <span class="dg">(4v)</span> <span class="db">K <k>test</k>/examine B for P with test V.</span></span></div> <div class="d_line"><span class="w_name">po prukao</span>, <span class="w_origin"><test act></span> <span class="definition eng" id=13531><span class="dg">(n)</span> <span class="db">a <k>test</k>/examination, an act of testing.</span></span></div>""" result = Word.translation_by_key("test", style="normal") assert result == expected_result_normal result = Word.translation_by_key("word_that_does_not_exist") assert result is None
def test_html_meaning(self): db_add_objects(Word, words) db_add_objects(Type, types) db_add_objects(Author, authors) db_add_objects(Definition, definitions) db_connect_authors(connect_authors) db_connect_words(connect_words) word = Word.get_by_id(7315) expected_result_ultra = """<m> <t><afx>pru</afx> <o><3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi></o> <tec>49% C-Prim L4 1975 1.9</tec></t> <ds> <dl>(3n) V is a <k>test</k>/<k>examination</k> for property B in any member of class F. [V‍-‍BF]</dl> <dl>(vt) <k>test</k>, test for … a property … in a member of ….</dl> <dl><du>fu —</du> (a) <k>testable</k>, of classes with -able members.</dl> <dl><du>nu —</du> (a) <k>testable</k>, of testable properties.</dl> </ds> <us>Used In: <use><cpx>prukao</cpx></use></us> </m>""" result = word.html_meaning(style="ultra") assert result == expected_result_ultra expected_result_normal = """<div class="meaning" id="7315"> <div class="technical"><span class="m_afx">pru</span> <span class="m_origin"><3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi></span> <span class="m_technical"><span class="m_match">49%</span> <span class="m_type">C-Prim</span> <span class="m_author">L4</span> <span class="m_year">1975</span> <span class="m_rank">1.9</span></span></div> <div class="definitions"> <div class="definition log" id=13523><span class="dg">(3n)</span> <span class="db">V is a <k>test</k>/<k>examination</k> for property B in any member of class F.</span> <span class="dt">[V‍-‍BF]</span></div> <div class="definition log" id=13524><span class="dg">(vt)</span> <span class="db"><k>test</k>, test for … a property … in a member of ….</span></div> <div class="definition log" id=13525><span class="du">fu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of classes with -able members.</span></div> <div class="definition log" id=13526><span class="du">nu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of testable properties.</span></div> </div> <div class="used_in">Used In: <span class="m_use"><a class="m_cpx">prukao</a></span></div> </div>""" result = word.html_meaning(style="normal") assert result == expected_result_normal
def test_export(self): """Test Word.export() method""" db_add_objects(Word, words) db_add_objects(Author, authors) db_add_objects(Type, types) db_connect_authors(connect_authors) db_connect_words(connect_words) word = Word.get_by_id(3813) result = word.export() assert result == "3880@C-Prim@Predicate@kak kao@56%@L4@[email protected]@3/3R akt " \ "| 4/4S acto | 3/3F acte | 2/3E act | 2/3H kam@@prukao@"
def test_meaning(self): """Test generating data for word's HTML block""" db_add_objects(Word, words) db_add_objects(Type, types) db_add_objects(Author, authors) db_add_objects(Definition, definitions) db_connect_authors(connect_authors) db_connect_words(connect_words) word = Word.get_by_id(7315) result = word.meaning(style="ultra") expected_value = { 'mid': 7315, 'technical': '<afx>pru</afx> <o><3/4E prove | 2/4C sh yen |' ' 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe |' ' 2/6J tameshi></o> <tec>49% C-Prim L4 1975 1.9</tec>', 'definitions': [ '<dl>(3n) V is a <k>test</k>/<k>examination</k> for property ' 'B in any member of class F. [V‍-‍BF]</dl>', '<dl>(vt) <k>test</k>, test for … a property … in a member of ….</dl>', '<dl><du>fu —</du> (a) <k>testable</k>, of classes with -able members.</dl>', '<dl><du>nu —</du> (a) <k>testable</k>, of testable properties.</dl>' ], 'used_in': '<use><cpx>prukao</cpx></use>' } assert isinstance(result, Meaning) assert result.__dict__ == expected_value word = Word.get_by_id(3802) result = word.meaning(style="normal") expected_value = { 'mid': 3802, 'technical': '<span class="m_origin"><kak(to)></span> <span class="m_technical">' '<span class="m_type">Afx</span> <span class="m_author">JCB</span> ' '<span class="m_year">1988</span> <span class="m_rank">7+</span></span>', 'definitions': [ '<div class="definition log" id=7240><span class="dg">(af)' '</span> <span class="db">a combining form of ' '<l>kakto</l>, <k>act</k>.</span></div>' ], 'used_in': None } assert isinstance(result, Meaning) assert result.__dict__ == expected_value
def test_authors_relationship(self): db_add_objects(Word, words) db_add_objects(Author, authors) db_connect_authors(connect_authors) word = Word.get_by_id(7316) author = Author.get_by_id(29) assert word.authors.count() == 1 assert word.authors[0] == author assert word.authors.first() == author assert isinstance(word.authors.all(), list) assert len(word.authors.all()) == 1
def test_relationship_contribution(self): db_add_objects(Author, authors) db_add_objects(Word, words) db_connect_authors(connect_authors) test_author = Author.get_by_id(29) assert len(test_author.contribution) == 3 assert isinstance(test_author.contribution, list) assert [w.name for w in test_author.contribution ] == ['kakto', 'pruci', 'prukao'] test_author = Author.get_by_id(13) assert len(test_author.contribution) == 3 assert [w.name for w in test_author.contribution] == ['kak', 'kao', 'pru']
def test_e_source(self): """Test source (authors) conversion""" db_add_objects(Word, words) db_add_objects(Author, authors) db_connect_authors(connect_authors) word = Word.get_by_id(3911) result = word.e_source assert result == "JCB (?)" db_add_object(Word, other_word_1) db_add_object(Author, other_author_1) db_connect_authors([(13, 1006), (36, 1006), ]) word = Word.get_by_id(1006) result = word.e_source assert result == "JCB/RAM"
def test_html_all_by_name(self): db_add_objects(Word, words) db_add_objects(Type, types) db_add_objects(Author, authors) db_add_objects(Event, events) db_add_objects(Definition, definitions) db_connect_authors(connect_authors) db_connect_words(connect_words) result = Word.html_all_by_name("buuku", style="ultra") assert result is None expected_result_ultra = """<ws> <w wid="pruci"><wl>pruci,</wl> <ms> <m> <t><afx>pru</afx> <o><3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi></o> <tec>49% C-Prim L4 1975 1.9</tec></t> <ds> <dl>(3n) V is a <k>test</k>/<k>examination</k> for property B in any member of class F. [V‍-‍BF]</dl> <dl>(vt) <k>test</k>, test for … a property … in a member of ….</dl> <dl><du>fu —</du> (a) <k>testable</k>, of classes with -able members.</dl> <dl><du>nu —</du> (a) <k>testable</k>, of testable properties.</dl> </ds> <us>Used In: <use><cpx>prukao</cpx></use></us> </m> </ms> </w> </ws> """ result = Word.html_all_by_name("pruci", style="ultra") assert result == expected_result_ultra expected_result_normal = """<div class="words"> <div class="word" wid="pruci"> <div class="word_line"><span class="word_name">pruci</span>,</div> <div class="meanings"> <div class="meaning" id="7315"> <div class="technical"><span class="m_afx">pru</span> <span class="m_origin"><3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi></span> <span class="m_technical"><span class="m_match">49%</span> <span class="m_type">C-Prim</span> <span class="m_author">L4</span> <span class="m_year">1975</span> <span class="m_rank">1.9</span></span></div> <div class="definitions"> <div class="definition log" id=13523><span class="dg">(3n)</span> <span class="db">V is a <k>test</k>/<k>examination</k> for property B in any member of class F.</span> <span class="dt">[V‍-‍BF]</span></div> <div class="definition log" id=13524><span class="dg">(vt)</span> <span class="db"><k>test</k>, test for … a property … in a member of ….</span></div> <div class="definition log" id=13525><span class="du">fu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of classes with -able members.</span></div> <div class="definition log" id=13526><span class="du">nu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of testable properties.</span></div> </div> <div class="used_in">Used In: <span class="m_use"><a class="m_cpx">prukao</a></span></div> </div> </div> </div> </div> """ result = Word.html_all_by_name("Pruci", style="normal") assert result == expected_result_normal result = Word.html_all_by_name("pruci", style="normal", event_id=1) assert result == expected_result_normal expected_result_normal = """<div class="words"> <div class="word" wid="pru"> <div class="word_line"><span class="word_name">pru</span>,</div> <div class="meanings"> <div class="meaning" id="7314"> <div class="technical"><span class="m_origin"><pru(ci)></span> <span class="m_technical"><span class="m_type">Afx</span> <span class="m_author">JCB</span> <span class="m_year">1988</span> <span class="m_rank">7+</span></span></div> <div class="definitions"> <div class="definition log" id=13521><span class="dg">(af)</span> <span class="db">a combining form of <l>pruci</l>, <k>test</k>.</span></div> </div> </div> </div> </div> <div class="word" wid="pruci"> <div class="word_line"><span class="word_name">pruci</span>,</div> <div class="meanings"> <div class="meaning" id="7315"> <div class="technical"><span class="m_afx">pru</span> <span class="m_origin"><3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi></span> <span class="m_technical"><span class="m_match">49%</span> <span class="m_type">C-Prim</span> <span class="m_author">L4</span> <span class="m_year">1975</span> <span class="m_rank">1.9</span></span></div> <div class="definitions"> <div class="definition log" id=13523><span class="dg">(3n)</span> <span class="db">V is a <k>test</k>/<k>examination</k> for property B in any member of class F.</span> <span class="dt">[V‍-‍BF]</span></div> <div class="definition log" id=13524><span class="dg">(vt)</span> <span class="db"><k>test</k>, test for … a property … in a member of ….</span></div> <div class="definition log" id=13525><span class="du">fu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of classes with -able members.</span></div> <div class="definition log" id=13526><span class="du">nu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of testable properties.</span></div> </div> <div class="used_in">Used In: <span class="m_use"><a class="m_cpx">prukao</a></span></div> </div> </div> </div> <div class="word" wid="prukao"> <div class="word_line"><span class="word_name">prukao</span>,</div> <div class="meanings"> <div class="meaning" id="7316"> <div class="technical"><span class="m_origin"><pru(ci)+ka(kt)o=test act></span> <span class="m_technical"><span class="m_type">2-Cpx</span> <span class="m_author">L4</span> <span class="m_year">1975</span> <span class="m_rank">1.9</span></span></div> <div class="definitions"> <div class="definition log" id=13527><span class="dg">(4v)</span> <span class="db">K <k>test</k>/<k>examine</k> B for P with test V.</span> <span class="dt">[K‍-‍BPV]</span></div> <div class="definition log" id=13528><span class="dg">(n)</span> <span class="db">a <k>tester</k>, one who uses tests.</span></div> <div class="definition log" id=13529><span class="du">nu —</span> <span class="dg">(a)</span> <span class="db"><k>testable</k>, of one who/that which is -ed.</span></div> <div class="definition log" id=13530><span class="du">nu —</span> <span class="dg">(n)</span> <span class="db">a <k>testee</k>, one who is -ed.</span></div> <div class="definition log" id=13531><span class="du">po —</span> <span class="dg">(n)</span> <span class="db">a <k>test</k>/<k>examination</k>, an act of testing.</span></div> </div> </div> </div> </div> </div> """ result = Word.html_all_by_name("pru*", style="normal", case_sensitive=True) assert result == expected_result_normal result = Word.html_all_by_name("Pru*", style="normal", case_sensitive=False) assert result == expected_result_normal