~launchpad-pqm/launchpad/devel

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
Language Pack storage
=====================

A LanguagePack represents an exported distribution series' language pack.

A LanuagePack is either a FULL or DELTA export.  If the LanguagePack is a
DELTA, there is also a reference to the related FULL LanguagePack.

A DELTA language pack is an export that has all translation resources that
were updated since the export date for the associate FULL export.

    >>> from zope.component import getUtility
    >>> from cStringIO import StringIO
    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> from lp.translations.enums import LanguagePackType
    >>> from lp.translations.interfaces.languagepack import (
    ...     ILanguagePack,
    ...     ILanguagePackSet)
    >>> from lp.services.webapp.testing import verifyObject
    >>> from lp.services.librarian.interfaces.client import ILibrarianClient

Let's upload a dummy file to librarian.

    >>> uploader = getUtility(ILibrarianClient)
    >>> content = 'foo'
    >>> file_alias = uploader.addFile(
    ...     name='foo.tar.gz',
    ...     size=len(content),
    ...     file=StringIO(content),
    ...     contentType='application/x-gtar')

We need too a distribution series to link the language pack with it.

    >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
    >>> hoary = ubuntu.getSeries('hoary')

We add the language pack.

    >>> language_pack_set = getUtility(ILanguagePackSet)
    >>> language_pack = language_pack_set.addLanguagePack(
    ...     hoary, file_alias, LanguagePackType.FULL)

And it implements and follow the ILanguagePack interface.

    >>> verifyObject(ILanguagePack, language_pack)
    True