|
1
|
|
|
# -*- coding: utf-8 -*- |
|
2
|
|
|
# pylint: disable=R0201, R0903 |
|
3
|
|
|
|
|
4
|
|
|
"""Export Model unit tests.""" |
|
5
|
|
|
|
|
6
|
|
|
import pytest |
|
7
|
|
|
|
|
8
|
|
|
from loglan_db.model_export import ExportAuthor as Author, ExportEvent as Event, \ |
|
9
|
|
|
ExportSyllable as Syllable, ExportSetting as Setting, ExportType as Type, \ |
|
10
|
|
|
ExportWord as Word, ExportDefinition as Definition, ExportWordSpell as WordSpell |
|
11
|
|
|
from tests.data import author_1, other_author_1, event_1, syllable_35, setting_1, type_1, word_1, other_word_1 |
|
12
|
|
|
from tests.data import connect_authors, connect_words |
|
13
|
|
|
from tests.data import definitions, words, types, authors |
|
14
|
|
|
from tests.functions import db_add_and_return, db_add_objects, db_add_object, \ |
|
15
|
|
|
db_connect_authors, db_connect_words |
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
@pytest.mark.usefixtures("db") |
|
19
|
|
|
class TestAuthor: |
|
20
|
|
|
"""Author tests.""" |
|
21
|
|
|
def test_export(self): |
|
22
|
|
|
"""Test Author.export() method""" |
|
23
|
|
|
obj = db_add_and_return(Author, author_1) |
|
24
|
|
|
|
|
25
|
|
|
result = obj.export() |
|
26
|
|
|
assert result == "L4@Loglan 4&5@The printed-on-paper " \ |
|
27
|
|
|
"book, 1975 version of the dictionary." |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
@pytest.mark.usefixtures("db") |
|
31
|
|
|
class TestEvent: |
|
32
|
|
|
"""Event tests.""" |
|
33
|
|
|
def test_export(self): |
|
34
|
|
|
"""Test Event.export() method""" |
|
35
|
|
|
obj = db_add_and_return(Event, event_1) |
|
36
|
|
|
|
|
37
|
|
|
result = obj.export() |
|
38
|
|
|
assert result == "1@Start@01/01/1975@The initial " \ |
|
39
|
|
|
"vocabulary before updates.@Initial@INIT" |
|
40
|
|
|
|
|
41
|
|
|
|
|
42
|
|
|
@pytest.mark.usefixtures("db") |
|
43
|
|
|
class TestSyllable: |
|
44
|
|
|
"""Syllable tests.""" |
|
45
|
|
|
def test_export(self): |
|
46
|
|
|
"""Test Syllable.export() method""" |
|
47
|
|
|
obj = db_add_and_return(Syllable, syllable_35) |
|
48
|
|
|
|
|
49
|
|
|
result = obj.export() |
|
50
|
|
|
assert result == "vr@InitialCC@True" |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
@pytest.mark.usefixtures("db") |
|
54
|
|
|
class TestSetting: |
|
55
|
|
|
"""Setting tests.""" |
|
56
|
|
|
def test_export(self): |
|
57
|
|
|
"""Test Setting.export() method""" |
|
58
|
|
|
obj = db_add_and_return(Setting, setting_1) |
|
59
|
|
|
|
|
60
|
|
|
result = obj.export() |
|
61
|
|
|
assert result == "09.10.2020 09:10:20@2@[email protected]" |
|
62
|
|
|
|
|
63
|
|
|
|
|
64
|
|
|
@pytest.mark.usefixtures("db") |
|
65
|
|
|
class TestType: |
|
66
|
|
|
"""Type tests.""" |
|
67
|
|
|
def test_export(self): |
|
68
|
|
|
"""Test Type.export() method""" |
|
69
|
|
|
obj = db_add_and_return(Type, type_1) |
|
70
|
|
|
|
|
71
|
|
|
result = obj.export() |
|
72
|
|
|
assert result == "2-Cpx@Predicate@Cpx@True@Two-term Complex " \ |
|
73
|
|
|
"E.g. flicea, from fli(du)+ce(nj)a=liquid-become." |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
@pytest.mark.usefixtures("db") |
|
77
|
|
|
class TestWord: |
|
78
|
|
|
"""Word tests.""" |
|
79
|
|
|
def test_export(self): |
|
80
|
|
|
"""Test Word.export() method""" |
|
81
|
|
|
db_add_objects(Word, words) |
|
82
|
|
|
db_add_objects(Author, authors) |
|
83
|
|
|
db_add_objects(Type, types) |
|
84
|
|
|
db_connect_authors(connect_authors) |
|
85
|
|
|
db_connect_words(connect_words) |
|
86
|
|
|
word = Word.get_by_id(3813) |
|
87
|
|
|
|
|
88
|
|
|
result = word.export() |
|
89
|
|
|
assert result == "3880@C-Prim@Predicate@kak kao@56%@L4@[email protected]@3/3R akt " \ |
|
90
|
|
|
"| 4/4S acto | 3/3F acte | 2/3E act | 2/3H kam@@prukao@" |
|
91
|
|
|
|
|
92
|
|
|
def test_e_affixes(self): |
|
93
|
|
|
"""Test affix conversion""" |
|
94
|
|
|
db_add_objects(Word, words) |
|
95
|
|
|
db_connect_words(connect_words) |
|
96
|
|
|
db_add_objects(Type, types) |
|
97
|
|
|
word = Word.get_by_id(3813) |
|
98
|
|
|
|
|
99
|
|
|
result = word.e_affixes |
|
100
|
|
|
assert result == "kak kao" |
|
101
|
|
|
|
|
102
|
|
|
def test_e_source(self): |
|
103
|
|
|
"""Test source (authors) conversion""" |
|
104
|
|
|
db_add_objects(Word, words) |
|
105
|
|
|
db_add_objects(Author, authors) |
|
106
|
|
|
db_connect_authors(connect_authors) |
|
107
|
|
|
word = Word.get_by_id(3911) |
|
108
|
|
|
|
|
109
|
|
|
result = word.e_source |
|
110
|
|
|
assert result == "JCB (?)" |
|
111
|
|
|
|
|
112
|
|
|
db_add_object(Word, other_word_1) |
|
113
|
|
|
db_add_object(Author, other_author_1) |
|
114
|
|
|
db_connect_authors([(13, 1006), (36, 1006), ]) |
|
115
|
|
|
word = Word.get_by_id(1006) |
|
116
|
|
|
|
|
117
|
|
|
result = word.e_source |
|
118
|
|
|
assert result == "JCB/RAM" |
|
119
|
|
|
|
|
120
|
|
|
def test_e_year(self): |
|
121
|
|
|
"""Test year conversion""" |
|
122
|
|
|
db_add_objects(Word, words) |
|
123
|
|
|
word = Word.get_by_id(3911) |
|
124
|
|
|
|
|
125
|
|
|
result = word.e_year |
|
126
|
|
|
assert result == "1988 (?)" |
|
127
|
|
|
|
|
128
|
|
|
def test_e_usedin(self): |
|
129
|
|
|
"""Test used_in conversion""" |
|
130
|
|
|
db_add_objects(Word, words) |
|
131
|
|
|
db_connect_words(connect_words) |
|
132
|
|
|
db_add_objects(Type, types) |
|
133
|
|
|
word = Word.get_by_id(3813) |
|
134
|
|
|
|
|
135
|
|
|
result = word.e_usedin |
|
136
|
|
|
assert result == "prukao" |
|
137
|
|
|
|
|
138
|
|
|
|
|
139
|
|
|
@pytest.mark.usefixtures("db") |
|
140
|
|
|
class TestDefinition: |
|
141
|
|
|
"""Definition tests.""" |
|
142
|
|
|
def test_export(self): |
|
143
|
|
|
"""Test Definition.export() method""" |
|
144
|
|
|
db_add_objects(Word, words) |
|
145
|
|
|
db_add_objects(Definition, definitions) |
|
146
|
|
|
definition = Definition.get_by_id(13527) |
|
147
|
|
|
|
|
148
|
|
|
result = definition.export() |
|
149
|
|
|
assert result == "7191@1@@4v@K «test»/«examine» B for P with test V.@@K-BPV" |
|
150
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
@pytest.mark.usefixtures("db") |
|
153
|
|
|
class TestWordSpell: |
|
154
|
|
|
"""WordSpell tests.""" |
|
155
|
|
|
def test_export(self): |
|
156
|
|
|
"""Test WordSpell.export() method""" |
|
157
|
|
|
obj = db_add_and_return(WordSpell, word_1) |
|
158
|
|
|
|
|
159
|
|
|
result = obj.export() |
|
160
|
|
|
assert result == "7191@prukao@prukao@555555@1@9999@" |
|
161
|
|
|
|