1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
1 |
Rosetta Translation Objects |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
2 |
=========================== |
3 |
||
4 |
This test demonstrates the complete hierarchy of Rosetta translation objects, |
|
5 |
from POTemplate down to POTranslation. |
|
5106.4.10
by Jeroen Vermeulen
Ported to Phase 2 API. |
6 |
|
7 |
Get a PO template. |
|
8 |
||
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
9 |
>>> from lp.translations.model.potemplate import POTemplate |
8751.1.10
by Danilo Šegan
Remove dependency on glob imports from most of the stuff. |
10 |
>>> template = POTemplate.get(1) |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
11 |
>>> template.name == 'evolution-2.2' |
5106.4.10
by Jeroen Vermeulen
Ported to Phase 2 API. |
12 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
13 |
|
14 |
Check that the PO template has a certain message ID. |
|
15 |
||
16 |
>>> from lp.translations.model.pomsgid import POMsgID |
|
8751.1.10
by Danilo Šegan
Remove dependency on glob imports from most of the stuff. |
17 |
>>> pomsgid = POMsgID.byMsgid('evolution addressbook') |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
18 |
>>> template.hasMessageID(pomsgid, None) |
6253.3.5
by Danilo Šegan
Fix remaining failing tests. |
19 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
20 |
|
21 |
Get a Spanish PO file for this PO template |
|
3200.1.1
by Carlos Perello Marin
Changed the way the import queue works and removed the old rawimports from POFile and POTemplate. Now we have just one place with all imports + a ton of tests fixes |
22 |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
23 |
>>> pofile = template.getPOFileByLang('es') |
24 |
||
25 |
Get a translation for a particular message and check it has a translation. |
|
5106.4.10
by Jeroen Vermeulen
Ported to Phase 2 API. |
26 |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
27 |
>>> potmsgset = factory.makePOTMsgSet(template) |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
28 |
>>> spanish = pofile.language |
5106.4.10
by Jeroen Vermeulen
Ported to Phase 2 API. |
29 |
>>> translations = factory.makeTranslationsDict() |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
30 |
>>> message = factory.makeCurrentTranslationMessage( |
31 |
... pofile, potmsgset, translations=translations) |
|
32 |
>>> translationmessage = potmsgset.getCurrentTranslation( |
|
33 |
... template, spanish, template.translation_side) |
|
34 |
>>> len(translationmessage.translations) |
|
35 |
1 |
|
36 |
>>> translationmessage.is_current_upstream |
|
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
37 |
True |
5106.3.8
by Danilo Šegan
Fix updateTranslation to override is_imported translation with is_imported translation. |
38 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
39 |
Get a person to create a translation with. |
1705
by Canonical.com Patch Queue Manager
[Trivial] POTemplate.hasMessageID was completely broken. Fixed and added a test |
40 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
41 |
>>> from lp.registry.model.person import Person |
8971.22.2
by Guilherme Salgado
Fix a bunch of tests to import registry model classes from lp.registry.model instead of from canonical.launchpad.database |
42 |
>>> person = Person.get(1) |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
43 |
>>> pofile.canEditTranslations(person) |
5106.3.8
by Danilo Šegan
Fix updateTranslation to override is_imported translation with is_imported translation. |
44 |
True |
45 |
||
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
46 |
Add a translation. |
1705
by Canonical.com Patch Queue Manager
[Trivial] POTemplate.hasMessageID was completely broken. Fixed and added a test |
47 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
48 |
>>> import pytz |
3691.273.3
by Carlos Perello Marin
More test fixes |
49 |
>>> UTC = pytz.timezone('UTC') |
50 |
>>> message = factory.makeCurrentTranslationMessage( |
|
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
51 |
... pofile, potmsgset, translations=translations, current_other=True) |
52 |
>>> message.is_current_ubuntu |
|
53 |
True |
|
54 |
>>> message.is_current_upstream |
|
55 |
True |
|
56 |
>>> from lp.services.database.sqlbase import flush_database_caches |
|
14606.3.1
by William Grant
Merge canonical.database into lp.services.database. |
57 |
>>> flush_database_caches() |
5106.3.8
by Danilo Šegan
Fix updateTranslation to override is_imported translation with is_imported translation. |
58 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
59 |
Check that this submission is now the active one for this msgset/pluralform |
60 |
||
61 |
>>> current = potmsgset.getCurrentTranslation( |
|
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
62 |
... template, spanish, template.translation_side) |
63 |
>>> current == message |
|
64 |
True |
|
65 |
>>> message.is_current_upstream |
|
66 |
True |
|
67 |
>>> message.msgstr0.translation == translations[0] |
|
68 |
True |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
69 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
70 |
Check that this submission is the upstream one |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
71 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
72 |
>>> potmsgset.getOtherTranslation( |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
73 |
... spanish, template.translation_side) == message |
74 |
True |
|
5106.4.10
by Jeroen Vermeulen
Ported to Phase 2 API. |
75 |
>>> message.is_current_upstream |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
76 |
True |
4069.3.4
by Carlos Perello Marin
Fixed a test after the modifications in this branch |
77 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
78 |
Test the origin enum column. |
1705
by Canonical.com Patch Queue Manager
[Trivial] POTemplate.hasMessageID was completely broken. Fixed and added a test |
79 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
80 |
>>> from lp.translations.interfaces.translationmessage import ( |
8751.1.10
by Danilo Šegan
Remove dependency on glob imports from most of the stuff. |
81 |
... RosettaTranslationOrigin) |
82 |
>>> message.origin == RosettaTranslationOrigin.ROSETTAWEB |
|
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
83 |
True |
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
84 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
85 |
Get a list of the translations again to check the new one has been added. |
1705
by Canonical.com Patch Queue Manager
[Trivial] POTemplate.hasMessageID was completely broken. Fixed and added a test |
86 |
|
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
87 |
>>> message.translations[0] == translations[0] |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
88 |
True |
89 |
||
1506
by Canonical.com Patch Queue Manager
convert fields in Rosetta to EnumCols, and add tests for database |
90 |
Now we want to test the interaction of the "upstream" translations with the |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
91 |
"active translations". There are several things we want to be able to test. |
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
92 |
First, let's setup some useful variables. |
93 |
||
94 |
>>> Pa = Person.get(50) |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
95 |
>>> Pb = Person.get(46) |
96 |
>>> Pc = Person.get(16) |
|
97 |
||
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
98 |
Pa, Pb and Pc are three useful Person's. |
99 |
||
100 |
Let's pretend we've seen a new translation in the upstream PO files for |
|
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
101 |
this project from Pa. |
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
102 |
|
103 |
>>> translations = { 0: u'bar' } |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
104 |
>>> upstream_message = factory.makeCurrentTranslationMessage( |
12221.15.4
by Abel Deuring
remove calls of updateTranslation() from rosetta-translation.txt |
105 |
... pofile, potmsgset=potmsgset, translator=Pa, |
106 |
... translations=translations, current_other=True) |
|
107 |
>>> flush_database_caches() |
|
5106.3.8
by Danilo Šegan
Fix updateTranslation to override is_imported translation with is_imported translation. |
108 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
109 |
Make sure that the new submission is in fact from Pa. |
110 |
||
111 |
>>> upstream_message.submitter == Pa |
|
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
112 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
113 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
114 |
This is marked as current in both Ubuntu and upstream. |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
115 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
116 |
>>> upstream_message.msgstr0.translation == u'bar' |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
117 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
118 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
119 |
>>> potmsgset.getCurrentTranslation( |
12221.15.11
by Aaron Bentley
Eliminate getImportedTranslationMessage. |
120 |
... template, spanish, template.translation_side) == upstream_message |
121 |
True |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
122 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
123 |
Excellent. This shows that activating a new upstream translation upon |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
124 |
detection works. |
125 |
||
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
126 |
Now, let's add a translation from Pb, through the web. |
127 |
||
128 |
>>> translations = { 0: u'baz' } |
|
1998
by Canonical.com Patch Queue Manager
TranslationValidation implementation for .po imports r=spiv |
129 |
>>> message = factory.makeCurrentTranslationMessage( |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
130 |
... pofile, potmsgset, translator=Pb, translations=translations) |
131 |
>>> flush_database_caches() |
|
5106.4.22
by Jeroen Vermeulen
Partial port to new API. |
132 |
>>> web_submission = potmsgset.getCurrentTranslation( |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
133 |
... template, spanish, template.translation_side) |
134 |
||
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
135 |
Make sure the new submission is from Pb. |
136 |
||
137 |
>>> web_submission.submitter == Pb |
|
5106.4.22
by Jeroen Vermeulen
Partial port to new API. |
138 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
139 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
140 |
This submission should now be active, but not from upstream. When we get a new |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
141 |
translation through the web, this updates the active selection but not the |
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
142 |
upstream selection. |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
143 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
144 |
>>> web_submission.msgstr0.translation == u'baz' |
5106.4.22
by Jeroen Vermeulen
Partial port to new API. |
145 |
True |
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
146 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
147 |
>>> potmsgset.getOtherTranslation( |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
148 |
... spanish, template.translation_side) == web_submission |
149 |
False |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
150 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
151 |
In fact, the upstream submission should still be the original one, from Pa: |
7675.916.98
by Henning Eggers
Merged db-stable at r10026 (recife roll-back) but without accepting the changes. |
152 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
153 |
>>> potmsgset.getOtherTranslation( |
12221.6.6
by Aaron Bentley
Fake merge of rollback at 12245:devel |
154 |
... spanish, template.translation_side) == upstream_message |
155 |
True |
|
1901
by Canonical.com Patch Queue Manager
RosettaLanguagePackExports [r=JamesH] |
156 |
|
1840
by Canonical.com Patch Queue Manager
restructure translation storage, allowing for wiki mode, non-editor translation, accurate statistics and fewer bugs |
157 |
And the lasttranslator for this pofile should be the one who submitted the |
5106.4.22
by Jeroen Vermeulen
Partial port to new API. |
158 |
current translation. |
159 |
||
2375
by Canonical.com Patch Queue Manager
Added initial support to show suggestions for multiline entries r=kiko |
160 |
>>> pofile.lasttranslator == Pb |
5106.4.22
by Jeroen Vermeulen
Partial port to new API. |
161 |
True |
2375
by Canonical.com Patch Queue Manager
Added initial support to show suggestions for multiline entries r=kiko |
162 |