1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
destroySelf
===========
(Note: this test runs as rosettaadmin to obtain the necessary
privileges)
With this method, we allow to remove a submission, it comes from SQLObject,
but we test it here to be sure it appears in our public interface.
We will need extra permissions to use this method.
>>> from lp.translations.model.translationmessage import (
... TranslationMessage)
>>> from lp.testing.layers import LaunchpadZopelessLayer
>>> LaunchpadZopelessLayer.switchDbUser('rosettaadmin')
Select an existing ITranslationMessage and try to remove it.
>>> translationmessage = TranslationMessage.get(1)
>>> translationmessage.destroySelf()
It should not exist now.
>>> translationmessage = TranslationMessage.get(1)
Traceback (most recent call last):
...
SQLObjectNotFound:...
POFileTranslator update on remove
=================================
In two sharing POTemplates with one shared POTMsgSet with one shared
translation, we get two POFileTranslator records for each of the POFiles.
>>> # We need to be able to create persons and projects so let's just use
>>> # a global 'postgres' permission which allows everything.
>>> LaunchpadZopelessLayer.switchDbUser('postgres')
>>> from lp.services.database.sqlbase import sqlvalues
>>> from lp.app.enums import ServiceUsage
>>> from lp.testing.factory import LaunchpadObjectFactory
>>> from lp.translations.model.pofiletranslator import POFileTranslator
>>> factory = LaunchpadObjectFactory()
>>> foo = factory.makeProduct(
... translations_usage=ServiceUsage.LAUNCHPAD)
>>> foo_devel = factory.makeProductSeries(
... name='devel', product=foo)
>>> foo_stable = factory.makeProductSeries(
... name='stable', product=foo)
>>> devel_potemplate = factory.makePOTemplate(
... productseries=foo_devel, name="messages")
>>> stable_potemplate = factory.makePOTemplate(foo_stable,
... name="messages")
>>> devel_sr_pofile = factory.makePOFile(
... 'sr', devel_potemplate)
>>> stable_sr_pofile = factory.makePOFile(
... 'sr', stable_potemplate)
>>> potmsgset = factory.makePOTMsgSet(devel_potemplate, sequence=1)
>>> item = potmsgset.setSequence(stable_potemplate, 1)
>>> tm = factory.makeCurrentTranslationMessage(
... pofile=devel_sr_pofile,
... potmsgset=potmsgset,
... translations=[u"blah"])
>>> print POFileTranslator.select(
... "latest_message=%s" % sqlvalues(tm)).count()
2
Removing a translation message triggers POFileTranslator row removal as well.
>>> tm.destroySelf()
>>> print list(POFileTranslator.select(
... "latest_message=%s" % sqlvalues(tm)))
[]
|