~launchpad-pqm/launchpad/devel

10427.25.4 by Henning Eggers
Really added test for new approver.
1
= TranslationBuildApprover =
2
3
The TranslationBuildApprover is a much simpler approver than the
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
4
TranslationBranchApprover. The latter tries to detect when templates have
5
been removed or renamed and refuses to approve anything when that happens.
6
This new approver does not care about these things but tries to approve as
7
many templates as possible. If this behavior proofs practical, it should
8
replace the TranslationBranchApprover in the future.
10427.25.4 by Henning Eggers
Really added test for new approver.
9
10
    >>> from lp.translations.interfaces.translationimportqueue import (
11
    ...     ITranslationImportQueue)
12
    >>> queue = getUtility(ITranslationImportQueue)
13
    >>> importer_person = factory.makePerson()
14
    >>> from lp.translations.model.approver import TranslationBuildApprover
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
15
    >>> def makeQueueEntry(path, series):
10427.25.4 by Henning Eggers
Really added test for new approver.
16
    ...     return queue.addOrUpdateEntry(
17
    ...         path, "#Dummy content.", False, importer_person,
10427.25.7 by Henning Eggers
Added another approval case.
18
    ...         productseries=series)
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
19
    >>> login("foo.bar@canonical.com")
20
21
It will approve all template files that it can derive a name from. It will
10427.25.12 by Henning Eggers
Added unit test for translationbranchapprover.
22
create a new template if none is found by that name.
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
23
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
24
    >>> productseries = factory.makeProductSeries()
25
    >>> approver = TranslationBuildApprover(
26
    ...     ["po/my_domain.pot"], productseries=productseries)
27
    >>> entry = makeQueueEntry("po/my_domain.pot", productseries)
28
    >>> print entry.status.title
10427.25.4 by Henning Eggers
Really added test for new approver.
29
    Needs Review
10427.25.39 by Henning Eggers
Final few fixes per review.
30
    >>> entry = approver.approve(entry)
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
31
    >>> print entry.status.title
10427.25.4 by Henning Eggers
Really added test for new approver.
32
    Approved
33
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
34
If a template with the name exists, it will target the import entry to it and
35
not create a new template.
36
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
37
    >>> productseries = factory.makeProductSeries()
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
38
    >>> existing_potemplate = factory.makePOTemplate(
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
39
    ...     name='existing-domain', productseries=productseries)
40
    >>> approver = TranslationBuildApprover(
41
    ...     ["po/existing_domain.pot"], productseries=productseries)
42
    >>> entry = makeQueueEntry(
43
    ...     "po/existing_domain.pot", productseries)
44
    >>> entry = approver.approve(entry)
45
    >>> print entry.status.title
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
46
    Approved
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
47
    >>> print entry.potemplate == existing_potemplate
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
48
    True
49
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
50
A template file with generic names is only approved if it is the only one that
51
is being imported and the series has zero or one templates. If no template
52
exists, a template with the name of the product is created.
10427.25.7 by Henning Eggers
Added another approval case.
53
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
54
    >>> product = factory.makeProduct(name='fooproduct')
55
    >>> productseries = factory.makeProductSeries(product=product)
56
    >>> generic_entry = makeQueueEntry('po/messages.pot', productseries)
57
    >>> approver = TranslationBuildApprover(
58
    ...     ['po/messages.pot'], productseries=productseries)
59
    >>> generic_entry = approver.approve(generic_entry)
60
    >>> print generic_entry.status.title
10427.25.7 by Henning Eggers
Added another approval case.
61
    Approved
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
62
    >>> print generic_entry.potemplate.translation_domain
63
    fooproduct
64
    >>> print generic_entry.potemplate.name
65
    fooproduct
66
67
If there are other files or templates, files with generic names are not
68
approved. Only the ones containing a translation domain are approved.
69
70
    >>> productseries = factory.makeProductSeries()
71
    >>> approver = TranslationBuildApprover(
10427.25.11 by Henning Eggers
Added files parameter to approver, adapted test.
72
    ...     ["po/messages.pot", "validdomain.pot"],
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
73
    ...     productseries=productseries)
74
    >>> generic_entry = makeQueueEntry("po/messages.pot", productseries)
75
    >>> generic_entry = approver.approve(generic_entry)
10427.25.4 by Henning Eggers
Really added test for new approver.
76
    >>> print generic_entry.status.title
77
    Needs Review
10427.25.35 by Henning Eggers
Refactoring and improved documentation per reviewer suggestions.
78
    >>> valid_entry = makeQueueEntry("validdomain.pot", productseries)
79
    >>> valid_entry = approver.approve(valid_entry)
10427.25.12 by Henning Eggers
Added unit test for translationbranchapprover.
80
    >>> print valid_entry.status.title
81
    Approved
10427.25.4 by Henning Eggers
Really added test for new approver.
82