Merge lp:~henninge/launchpad/bug-446160 into lp:launchpad

Proposed by Henning Eggers
Status: Merged
Merged at revision: not available
Proposed branch: lp:~henninge/launchpad/bug-446160
Merge into: lp:launchpad
Diff against target: 39 lines
2 files modified
lib/lp/translations/model/translationbranchapprover.py (+2/-1)
lib/lp/translations/tests/test_translationbranchapprover.py (+17/-0)
To merge this branch: bzr merge lp:~henninge/launchpad/bug-446160
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) code Approve
Review via email: mp+13558@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Henning Eggers (henninge) wrote :

= Details =
See bug 446160

This branch fixes the bug by checking the state of an entry before setting it to approved.

== Tests ==
bin/test -vvct TranslationBranchApprover

== Demo/QA ==
1. Push a branch with a translation template file to a project on LP.
2. Select that branch as series branch and request a one-time import.
3. Wait for the file to appear in the queue. It should be "Approved". No need for it to wait for it to become "Imported".
4. Set the file to "Deleted" or "Blocked".
5. Change the file and push the branch again.
6. Request another one-time import.
7. The date on the queue entry will change but the state should not change to "Approved" again but remain "Deleted" or "Blocked", as selected in step 4.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/model/translationbranchapprover.py
  lib/lp/translations/tests/test_translationbranchapprover.py

Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Discussed on IRC. Looks fine, apart from a missing word in a comment and the naming of the test function.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/model/translationbranchapprover.py'
2--- lib/lp/translations/model/translationbranchapprover.py 2009-08-06 15:14:02 +0000
3+++ lib/lp/translations/model/translationbranchapprover.py 2009-10-20 09:59:13 +0000
4@@ -164,6 +164,7 @@
5
6 # Approve the entry
7 entry.potemplate = potemplate
8- entry.setStatus(RosettaImportStatus.APPROVED)
9+ if entry.status == RosettaImportStatus.NEEDS_REVIEW:
10+ entry.setStatus(RosettaImportStatus.APPROVED)
11 return entry
12
13
14=== modified file 'lib/lp/translations/tests/test_translationbranchapprover.py'
15--- lib/lp/translations/tests/test_translationbranchapprover.py 2009-08-06 15:14:02 +0000
16+++ lib/lp/translations/tests/test_translationbranchapprover.py 2009-10-20 09:59:13 +0000
17@@ -202,5 +202,22 @@
18 approver.approve(entry2)
19 self.assertEqual(RosettaImportStatus.NEEDS_REVIEW, entry2.status)
20
21+ def test_approve_only_if_needs_review(self):
22+ # If an entry is not in NEEDS_REVIEW state, it must not be approved.
23+ pot_path = self.factory.getUniqueString()+".pot"
24+ entry = self._upload_file(pot_path)
25+ not_approve_status = (
26+ RosettaImportStatus.IMPORTED,
27+ RosettaImportStatus.DELETED,
28+ RosettaImportStatus.FAILED,
29+ RosettaImportStatus.BLOCKED,
30+ )
31+ for status in not_approve_status:
32+ entry.setStatus(status)
33+ approver = self._create_approver(pot_path)
34+ approver.approve(entry)
35+ self.assertEqual(status, entry.status)
36+
37 def test_suite():
38 return TestLoader().loadTestsFromName(__name__)
39+