← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/test-no-sequence-deps-translations into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/test-no-sequence-deps-translations into lp:launchpad with lp:~wgrant/launchpad/test-no-sequence-deps as a prerequisite.

Commit message:
Fix Translations tests to cope with sequences not being reset between tests.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/test-no-sequence-deps-translations/+merge/273382

Fix Translations tests to cope with sequences not being reset between tests.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/test-no-sequence-deps-translations into lp:launchpad.
=== modified file 'lib/lp/translations/browser/tests/pofile-views.txt'
--- lib/lp/translations/browser/tests/pofile-views.txt	2014-02-19 04:01:46 +0000
+++ lib/lp/translations/browser/tests/pofile-views.txt	2015-10-05 09:27:21 +0000
@@ -397,7 +397,9 @@
 
 Get it and check that some attributes are set as they should.
 
-    >>> entry = translationimportqueue.get(3)
+    >>> from lp.translations.enums import RosettaImportStatus
+    >>> entry = translationimportqueue.getAllEntries(
+    ...     import_status=RosettaImportStatus.NEEDS_REVIEW)[-1]
     >>> entry.pofile == pofile_es
     True
 

=== modified file 'lib/lp/translations/browser/tests/potemplate-views.txt'
--- lib/lp/translations/browser/tests/potemplate-views.txt	2014-02-19 04:01:46 +0000
+++ lib/lp/translations/browser/tests/potemplate-views.txt	2015-10-05 09:27:21 +0000
@@ -64,7 +64,9 @@
 Get it and check that some attributes are set as they should. For instance,
 the entry should be linked with the IPOTemplate we are using.
 
-    >>> entry = translationimportqueue.get(3)
+    >>> from lp.translations.enums import RosettaImportStatus
+    >>> entry = translationimportqueue.getAllEntries(
+    ...     import_status=RosettaImportStatus.NEEDS_REVIEW)[-1]
     >>> entry.potemplate == potemplate
     True
 
@@ -93,7 +95,8 @@
 Get it and check that some attributes are set as they should. For instance,
 the entry should be linked with the IPOTemplate we are using.
 
-    >>> entry = translationimportqueue.get(4)
+    >>> entry = translationimportqueue.getAllEntries(
+    ...     import_status=RosettaImportStatus.NEEDS_REVIEW)[-1]
     >>> entry.potemplate == potemplate
     True
 

=== modified file 'lib/lp/translations/browser/tests/translationmessage-views.txt'
--- lib/lp/translations/browser/tests/translationmessage-views.txt	2014-06-13 07:44:10 +0000
+++ lib/lp/translations/browser/tests/translationmessage-views.txt	2015-10-05 09:27:21 +0000
@@ -446,20 +446,20 @@
     ...     if not attr.startswith('_'):
     ...         print "%s: %s" % (attr, getattr(submission, attr))
     date_created: ...
-    id: 703
+    id: ...
     is_empty: False
     is_local_to_pofile: False
     is_traversable: ...
     language: ...
     legal_warning: False
-    origin_html_id: msgset_15_ja_suggestion_703_0_origin
+    origin_html_id: msgset_15_ja_suggestion_..._0_origin
     person: ...
     plural_index: 0
     pofile: ...
     potmsgset: ...
     row_html_id: 
     suggestion_dismissable_class: msgset_15_dismissable_button
-    suggestion_html_id: msgset_15_ja_suggestion_703_0
+    suggestion_html_id: msgset_15_ja_suggestion_..._0
     suggestion_text: Foo <code>%d</code>
     translation_html_id: msgset_15_es_translation_0
     translationmessage: ...

=== modified file 'lib/lp/translations/doc/translationimportqueue.txt'
--- lib/lp/translations/doc/translationimportqueue.txt	2013-06-20 05:50:00 +0000
+++ lib/lp/translations/doc/translationimportqueue.txt	2015-10-05 09:27:21 +0000
@@ -793,31 +793,35 @@
 
 First, let's check the status of the existing entries.
 
-    >>> entry1 = translationimportqueue.get(1)
+    >>> from operator import attrgetter
+    >>> entries = sorted(
+    ...     translationimportqueue.getAllEntries(), key=attrgetter('id'))
+
+    >>> entry1 = entries[0]
     >>> entry1.path
     u'po/evolution-2.2-test.pot'
     >>> entry1.status == RosettaImportStatus.IMPORTED
     True
 
-    >>> entry2 = translationimportqueue.get(2)
+    >>> entry2 = entries[1]
     >>> entry2.path
     u'po/pt_BR.po'
     >>> entry2.status == RosettaImportStatus.IMPORTED
     True
 
-    >>> entry3 = translationimportqueue.get(3)
+    >>> entry3 = entries[2]
     >>> entry3.path
     u'po/sr.po'
     >>> entry3.status == RosettaImportStatus.NEEDS_REVIEW
     True
 
-    >>> entry4 = translationimportqueue.get(4)
+    >>> entry4 = entries[3]
     >>> entry4.path
     u'po/sr.po'
     >>> entry4.status == RosettaImportStatus.NEEDS_REVIEW
     True
 
-    >>> entry5 = translationimportqueue.get(5)
+    >>> entry5 = entries[4]
     >>> entry5.path
     u'po/evolution-2.2.pot'
 
@@ -833,7 +837,6 @@
 
 Now is time to check that we only have one item on the NeedsReview status.
 
-    >>> entry3 = translationimportqueue.get(3)
     >>> entry3.path
     u'po/sr.po'
 
@@ -847,7 +850,6 @@
 distroseries/sourcepackagename than the .pot file we have so it's also
 blocked.
 
-    >>> entry4 = translationimportqueue.get(4)
     >>> entry4.path
     u'po/sr.po'
     >>> entry4.status == RosettaImportStatus.BLOCKED
@@ -855,7 +857,6 @@
 
 And the .pot entry is still blocked.
 
-    >>> entry5 = translationimportqueue.get(5)
     >>> entry5.path
     u'po/evolution-2.2.pot'
     >>> entry5.status == RosettaImportStatus.BLOCKED

=== modified file 'lib/lp/translations/stories/importqueue/xx-translation-import-queue-edit-autofilling.txt'
--- lib/lp/translations/stories/importqueue/xx-translation-import-queue-edit-autofilling.txt	2010-07-13 15:40:33 +0000
+++ lib/lp/translations/stories/importqueue/xx-translation-import-queue-edit-autofilling.txt	2015-10-05 09:27:21 +0000
@@ -27,7 +27,15 @@
 Let's check the values we get by default from the .pot file. The name field
 and the translation domain field are pre-filled from the name of the file.
 
-  >>> browser.open('http://translations.launchpad.dev/+imports/4')
+  >>> login(ANONYMOUS)
+  >>> from zope.component import getUtility
+  >>> from lp.registry.interfaces.product import IProductSet
+  >>> series = getUtility(IProductSet).getByName('alsa-utils').getSeries('trunk')
+  >>> pot_qid = series.getTranslationImportQueueEntries(file_extension='pot')[0].id
+  >>> po_qid = series.getTranslationImportQueueEntries(file_extension='po')[0].id
+  >>> logout()
+
+  >>> browser.open('http://translations.launchpad.dev/+imports/%d' % pot_qid)
   >>> browser.getControl(name='field.name').value
   'test'
   >>> browser.getControl(name='field.translation_domain').value
@@ -52,14 +60,14 @@
 Now, as we already know the name, a new form load should
 give us that field with information.
 
-  >>> browser.open('http://translations.launchpad.dev/+imports/4')
+  >>> browser.open('http://translations.launchpad.dev/+imports/%d' % pot_qid)
   >>> browser.getControl(name='field.name').value
   'alsa-utils'
 
 Let's move to the .po file. The language is guessed from the file name
 and the user sees a warning so he checks that it's ok.
 
-  >>> browser.open('http://translations.launchpad.dev/+imports/3')
+  >>> browser.open('http://translations.launchpad.dev/+imports/%d' % po_qid)
   >>> browser.getControl(name='field.file_type').value
   ['PO']
   >>> browser.getControl(name='field.path').value
@@ -81,7 +89,7 @@
 
 Reloading the form shows all the submitted information applied.
 
-  >>> browser.open('http://translations.launchpad.dev/+imports/3')
+  >>> browser.open('http://translations.launchpad.dev/+imports/%d' % po_qid)
   >>> browser.getControl(name='field.path').value
   'po/es.po'
   >>> browser.getControl(name='field.potemplate').value

=== modified file 'lib/lp/translations/stories/importqueue/xx-translation-import-queue-filtering.txt'
--- lib/lp/translations/stories/importqueue/xx-translation-import-queue-filtering.txt	2011-07-13 06:08:16 +0000
+++ lib/lp/translations/stories/importqueue/xx-translation-import-queue-filtering.txt	2015-10-05 09:27:21 +0000
@@ -32,6 +32,18 @@
     <div...Thank you for your upload. 100 files from the tarball will be
     automatically reviewed...
 
+    >>> from zope.component import getUtility
+    >>> from lp.registry.interfaces.product import IProductSet
+    >>> from lp.translations.enums import RosettaImportStatus
+    >>> login(ANONYMOUS)
+    >>> evo = getUtility(IProductSet).getByName('evolution')
+    >>> trunk = evo.getSeries('trunk')
+    >>> queue_entries = trunk.getTranslationImportQueueEntries(
+    ...     import_status=RosettaImportStatus.NEEDS_REVIEW)
+    >>> qid1 = queue_entries[0].id
+    >>> qid2 = queue_entries[1].id
+    >>> logout()
+
 On the import queue page, Carlos sees widgets for filtering his view of
 the queue, as well as the entries he just imported and the two that were
 already included in the sample data.
@@ -169,9 +181,9 @@
 Carlos changes the status of the third entry to Blocked.
 
     >>> browser.open('http://translations.launchpad.dev/+imports')
-    >>> browser.getControl(name='field.status_3').value
+    >>> browser.getControl(name='field.status_%d' % qid1).value
     ['NEEDS_REVIEW']
-    >>> browser.getControl(name='field.status_3').value = ['BLOCKED']
+    >>> browser.getControl(name='field.status_%d' % qid1).value = ['BLOCKED']
     >>> browser.getControl('Change status').click()
     >>> print browser.url
     http://translations.launchpad.dev/+imports/+index
@@ -181,7 +193,7 @@
     >>> browser.open(
     ...     'http://translations.launchpad.dev/+imports?'
     ...     'field.filter_status=BLOCKED&field.filter_extension=all')
-    >>> browser.getControl(name='field.status_3').value
+    >>> browser.getControl(name='field.status_%s' % qid1).value
     ['BLOCKED']
     >>> print_batch_heading(browser)
     1 ... 1 of 1 result
@@ -207,9 +219,9 @@
 The fourth entry, Carlos deletes by setting its status to Deleted.
 
     >>> browser.open('http://translations.launchpad.dev/+imports')
-    >>> browser.getControl(name='field.status_4').value
+    >>> browser.getControl(name='field.status_%d' % qid2).value
     ['NEEDS_REVIEW']
-    >>> browser.getControl(name='field.status_4').value = ['DELETED']
+    >>> browser.getControl(name='field.status_%d' % qid2).value = ['DELETED']
     >>> browser.getControl('Change status').click()
     >>> browser.url
     'http://translations.launchpad.dev/+imports/+index'
@@ -219,7 +231,7 @@
     >>> browser.open(
     ...     'http://translations.launchpad.dev/+imports?'
     ...     'field.filter_status=DELETED&field.filter_extension=all')
-    >>> browser.getControl(name='field.status_4').value
+    >>> browser.getControl(name='field.status_%d' % qid2).value
     ['DELETED']
     >>> print_batch_heading(browser)
     1 ... 1 of 1 result

=== modified file 'lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt'
--- lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt	2014-01-30 09:58:18 +0000
+++ lib/lp/translations/stories/importqueue/xx-translation-import-queue.txt	2015-10-05 09:27:21 +0000
@@ -97,9 +97,11 @@
   True
   >>> 'Mozilla Firefox 1.0 series' in browser.contents
   True
-  >>> browser.getLink(url='+imports/3')
-  <Link text='Change this entry' url='http://translations.launchpad.dev/+imports/3'>
-  >>> browser.getControl(name='field.status_3').displayValue
+  >>> link = browser.getLink('Change this entry', index=2)
+  >>> link
+  <Link text='Change this entry' url='http://translations.launchpad.dev/+imports/...'>
+  >>> qid = int(link.url.rsplit('/', 1)[-1])
+  >>> browser.getControl(name='field.status_%d' % qid).displayValue
   ['Needs Review']
 
 Now, we attach a new file to an already existing translation resource.
@@ -137,7 +139,7 @@
 Open the edit form for the third entry.
 
   >>> browser.open('http://translations.launchpad.dev/+imports')
-  >>> browser.getLink(url='imports/3').click()
+  >>> browser.getLink(url='imports/%d' % qid).click()
 
 And provide information for this IPOTemplate to be newly created. Invalid
 names for the template are rejected.
@@ -148,7 +150,7 @@
   >>> browser.getControl('Translation domain').value = 'pkgconf-mozilla'
   >>> browser.getControl('Approve').click()
   >>> print browser.url
-  http://translations.launchpad.dev/+imports/3/+index
+  http://translations.launchpad.dev/+imports/.../+index
   >>> message = find_tags_by_class(browser.contents, 'message')[1]
   >>> print message.string
   Please specify a valid name...
@@ -168,12 +170,13 @@
 there doesn't help.
 
   >>> browser.open('http://translations.launchpad.dev/+imports')
-  >>> browser.getLink(url='imports/4').click()
+  >>> browser.getLink(url='imports/%d' % (qid + 1)).click()
 
 And provide information for this IPOFile to be newly created.
 
   >>> browser.getControl('File Type').value = ['PO']
-  >>> browser.getControl(name='field.potemplate').value = ['11']
+  >>> browser.getControl(name='field.potemplate').displayValue = [
+  ...     'pkgconf-mozilla']
   >>> browser.getControl('Language').value = ['es']
   >>> browser.getControl('Approve').click()
   >>> print browser.url
@@ -268,9 +271,10 @@
 own imports.
 
   >>> ff_owner_browser.open('http://translations.launchpad.dev/+imports')
-  >>> ff_owner_browser.getControl(name='field.status_4').value
+  >>> status = ff_owner_browser.getControl(name='field.status_%d' % (qid + 1))
+  >>> status.value
   ['APPROVED']
-  >>> ff_owner_browser.getControl(name='field.status_4').value = ['DELETED']
+  >>> status.value = ['DELETED']
   >>> ff_owner_browser.getControl('Change status').click()
 
 The entry now appears deleted.
@@ -278,7 +282,7 @@
   >>> print find_main_content(ff_owner_browser.contents)
   <...po/es.po...
   ...Mozilla Firefox 1.0 series...
-  ...field.status_4...
+  ...field.status_...
   ...selected="selected" value="DELETED"...
   ...Sample Person...
   ...Spanish (es) translation of pkgconf-mozilla in Mozilla Firefox 1.0...

=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-translate-dismiss-suggestions.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-translate-dismiss-suggestions.txt	2011-12-22 05:09:10 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-translate-dismiss-suggestions.txt	2015-10-05 09:27:21 +0000
@@ -49,11 +49,13 @@
 
 But it's only a suggestion, so the translation remains unchanged.
 
+    >>> import re
     >>> print extract_text(find_tag_by_id(user_browser.contents,
     ...                                   'msgset_198_de_translation_0'))
     The great new translation.
-    >>> print extract_text(find_tag_by_id(user_browser.contents,
-    ...                                   'msgset_198_de_suggestion_705_0'))
+    >>> print extract_text(find_tag_by_id(
+    ...     user_browser.contents,
+    ...     re.compile(r'^msgset_198_de_suggestion_\d+_0$')))
     The really bad suggestion.
 
 In order to get rid of this, the admin chooses to keep the great new

=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt	2014-11-27 22:13:36 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-translate-message-filtering.txt	2015-10-05 09:27:21 +0000
@@ -220,7 +220,7 @@
     >>> user_browser.getLink('Previous').click()
     >>> contents = find_main_content(user_browser.contents)
     >>> contents.find(text='fnord').parent
-    <div lang="en-AU"...id="msgset_1_en_AU_suggestion_702_0"...>fnord</div>
+    <div lang="en-AU"...id="msgset_1_en_AU_suggestion_..._0"...>fnord</div>
 
 
 Messages changed in Ubuntu

=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-translate-needs-review-flags-preserved.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-translate-needs-review-flags-preserved.txt	2010-04-12 19:34:06 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-translate-needs-review-flags-preserved.txt	2015-10-05 09:27:21 +0000
@@ -54,8 +54,10 @@
 
 But a new suggestion is provided for this message.
 
-    >>> print extract_text(find_tag_by_id(user_browser.contents,
-    ...                                   'msgset_130_es_suggestion_701_0'))
+    >>> import re
+    >>> print extract_text(find_tag_by_id(
+    ...     user_browser.contents,
+    ...     re.compile(r'^msgset_130_es_suggestion_\d+_0$')))
     New suggestion
 
 

=== modified file 'lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt'
--- lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt	2014-07-02 04:41:13 +0000
+++ lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt	2015-10-05 09:27:21 +0000
@@ -455,10 +455,16 @@
 
 But also, the new one should appear in the form.
 
-    >>> find_tag_by_id(
-    ...     slow_submission.contents,
-    ...     'msgset_143_es_suggestion_703_0').renderContents()
-    'foo!!'
+    >>> import re
+    >>> elements = find_main_content(slow_submission.contents).findAll(
+    ...     True, {'id': re.compile(r'^msgset_143_es_suggestion_\d+_0$')})
+    >>> for element in elements:
+    ...     print element.renderContents()
+    La ubicación ...
+    Tenga paciencia ...
+    foo!!
+    This is a suggestion ...
+    It should work! :-P
 
 
 Unreviewed translations

=== modified file 'lib/lp/translations/stories/standalone/xx-translations-xpi-import.txt'
--- lib/lp/translations/stories/standalone/xx-translations-xpi-import.txt	2010-12-22 14:50:08 +0000
+++ lib/lp/translations/stories/standalone/xx-translations-xpi-import.txt	2015-10-05 09:27:21 +0000
@@ -37,9 +37,10 @@
   >>> browser.getLink('Translation Import Queue').click()
   >>> print browser.getLink(url='en-US.xpi').url
   http://.../en-US.xpi
-  >>> browser.getLink(url='imports/3').click()
+  >>> browser.getLink(url='/+imports/').click()
   >>> print browser.url
-  http://translations.launchpad.dev/+imports/3
+  http://translations.launchpad.dev/+imports/...
+  >>> qid = int(browser.url.rsplit('/', 1)[-1])
 
 All new entries need to get a template name to identify them in the context
 where will be imported. In this case, it's 'firefox'.
@@ -50,5 +51,5 @@
   >>> browser.getControl('Approve').click()
   >>> print browser.url
   http://translations.launchpad.dev/firefox/trunk/+imports
-  >>> browser.getControl(name='field.status_3').value
+  >>> browser.getControl(name='field.status_%d' % qid).value
   ['APPROVED']

=== modified file 'lib/lp/translations/stories/translationgroups/xx-translationgroups.txt'
--- lib/lp/translations/stories/translationgroups/xx-translationgroups.txt	2015-06-15 08:35:10 +0000
+++ lib/lp/translations/stories/translationgroups/xx-translationgroups.txt	2015-10-05 09:27:21 +0000
@@ -1216,32 +1216,16 @@
 
 Now, we can see the added suggestion + others from the sample data.
 
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_703_0")
+    >>> for suggestion in find_main_content(browser.contents).findAll(
+    ...         True, {'id': re.compile('msgset_134_es_suggestion_.*')}):
+    ...     print suggestion
     <...<samp> </samp>new suggestion...
-
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_703_0_origin")
     <...
     ...Suggested by...No Privileges Person...
-
-These are old suggestions:
-
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_698_0")
     <...<samp> </samp>Srprise! (non-editor)...
-
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_698_0_origin")
     <...
     ...Suggested by...Valentina Commissari...2005-06-06...
-
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_696_0")
     <...<samp> </samp>bang bang in evo hoary...
-
-    >>> print find_tag_by_id(
-    ...     browser.contents, "msgset_134_es_suggestion_696_0_origin")
     <...
     ...Suggested in...evolution-2.2 in Evolution trunk...
     ...Mark Shuttleworth</a>...2005-06-06...


Follow ups