Ejemplo n.º 1
0
    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>&lt;3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi&gt;</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&zwj;-&zwj;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">&lt;3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi&gt;</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&zwj;-&zwj;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
Ejemplo n.º 2
0
    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&zwj;-&zwj;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>&lt;test act&gt;</o> <de>[K&zwj;-&zwj;BPV] (4v) K <k>test</k>/examine B for P with test V.</de></ld>
<ld><wn>po prukao</wn>, <o>&lt;test act&gt;</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&zwj;-&zwj;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">&lt;test act&gt;</span> <span class="definition eng" id=13527><span class="dt">[K&zwj;-&zwj;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">&lt;test act&gt;</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
Ejemplo n.º 3
0
    def test_derivatives(self):
        db_add_objects(Word, words)
        db_connect_words(connect_words)

        p1 = Word.get_by_id(3813)

        assert isinstance(p1.derivatives, BaseQuery)
        assert p1.derivatives.count() == 3
Ejemplo n.º 4
0
    def test_parents(self):
        db_add_objects(Word, words)
        db_connect_words(connect_words)

        result = Word.get_by_id(7316).parents

        assert len(result.all()) == 2
        assert isinstance(result, BaseQuery)
        assert isinstance(result[0], Word)
Ejemplo n.º 5
0
    def test_e_affixes(self):
        """Test affix conversion"""
        db_add_objects(Word, words)
        db_connect_words(connect_words)
        db_add_objects(Type, types)
        word = Word.get_by_id(3813)

        result = word.e_affixes
        assert result == "kak kao"
Ejemplo n.º 6
0
    def test_affixes(self):
        db_add_objects(Word, words)
        db_add_objects(Type, types)
        db_connect_words(connect_words)

        result = Word.get_by_id(3813).affixes

        assert len(result.all()) == 2
        assert isinstance(result, BaseQuery)
        assert isinstance(result[0], Word)
Ejemplo n.º 7
0
    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@"
Ejemplo n.º 8
0
    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>&lt;3/4E prove | 2/4C sh yen |'
            ' 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe |'
            ' 2/6J tameshi&gt;</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&zwj;-&zwj;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">&lt;kak(to)&gt;</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
Ejemplo n.º 9
0
    def test_e_usedin(self):
        """Test used_in conversion"""
        db_add_objects(Word, words)
        db_connect_words(connect_words)
        db_add_objects(Type, types)
        word1 = Word.get_by_id(3813)

        result = word1.e_usedin
        assert result == "prukao"

        word2 = Word.get_by_id(7316)

        result = word2.e_usedin
        assert result == ""
Ejemplo n.º 10
0
    def test_query_derivatives(self):
        db_add_objects(Word, words)
        db_add_objects(Type, types)
        db_connect_words(connect_words)

        p1 = Word.get_by_id(3813)
        p2 = Word.get_by_id(7315)

        assert p1.query_derivatives().count() == 3
        assert p2.query_derivatives().count() == 2
        assert isinstance(p2.query_derivatives().first(), Word)

        assert p1.query_derivatives(word_type="Afx").count() == 2
        assert p1.query_derivatives(word_type="2-Cpx").count() == 1

        assert p1.query_derivatives(word_type_x="Predicate").count() == 1
        assert p2.query_derivatives(word_type_x="Affix").count() == 1

        assert p1.query_derivatives(word_group="Little").count() == 2
        assert p2.query_derivatives(word_group="Cpx").count() == 1
Ejemplo n.º 11
0
    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>&lt;3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi&gt;</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&zwj;-&zwj;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">&lt;3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi&gt;</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&zwj;-&zwj;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">&lt;pru(ci)&gt;</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">&lt;3/4E prove | 2/4C sh yen | 3/6S prueba | 2/5R proba | 2/5F epreuve | 2/5G probe | 2/6J tameshi&gt;</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&zwj;-&zwj;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">&lt;pru(ci)+ka(kt)o=test act&gt;</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&zwj;-&zwj;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