Code review comment for lp:~adiroiban/launchpad/bug-525371

Revision history for this message
Adi Roiban (adiroiban) wrote :

Hi,

I have improved the tests to check for templates count from the db.

Here is the latest diff:

=== modified file 'lib/lp/registry/stories/webservice/xx-distroseries.txt'
--- lib/lp/registry/stories/webservice/xx-distroseries.txt 2010-05-17 09:35:18 +0000
+++ lib/lp/registry/stories/webservice/xx-distroseries.txt 2010-05-18 14:51:40 +0000
@@ -107,9 +107,19 @@
 All templates associated to a distribution series are available at the
 'all_translation_templates' collection link.

+ >>> from zope.component import getUtility
+ >>> from canonical.launchpad.interfaces.launchpad import (
+ ... ILaunchpadCelebrities)
+ >>> from lp.translations.interfaces.potemplate import IPOTemplateSet
+ >>> login('<email address hidden>')
+ >>> hoary = getUtility(ILaunchpadCelebrities).ubuntu.getSeries('hoary')
+ >>> templates = getUtility(IPOTemplateSet).getSubset(distroseries=hoary)
+ >>> db_count = len(list(templates))
+ >>> logout()
     >>> all_translation_templates = anon_webservice.get(
     ... '/ubuntu/hoary/all_translation_templates').jsonBody()
- >>> print all_translation_templates['total_size']
- 6
+ >>> api_count = all_translation_templates['total_size']
+ >>> api_count == db_count
+ True
     >>> print(all_translation_templates['entries'][0]['resource_type_link'])
     http://.../#potemplate

=== modified file 'lib/lp/registry/stories/webservice/xx-project-registry.txt'
--- lib/lp/registry/stories/webservice/xx-project-registry.txt 2010-05-17 09:35:18 +0000
+++ lib/lp/registry/stories/webservice/xx-project-registry.txt 2010-05-18 15:10:45 +0000
@@ -897,11 +897,20 @@
 "all_translation_templates" will list all POTemplates associated with this
 product series.

+
+ >>> from zope.component import getUtility
+ >>> from lp.translations.interfaces.potemplate import IPOTemplateSet
+ >>> login('<email address hidden>')
+ >>> templates = getUtility(
+ ... IPOTemplateSet).getSubset(productseries=foobadoo)
+ >>> db_count = len(list(templates))
+ >>> logout()
     >>> all_translation_templates = anon_webservice.get(
     ... babadoo_foobadoo[
     ... 'all_translation_templates_collection_link']).jsonBody()
- >>> print all_translation_templates['total_size']
- 1
+ >>> api_count = all_translation_templates['total_size']
+ >>> api_count == db_count
+ True
     >>> print(all_translation_templates['entries'][0]['resource_type_link'])
     http://.../#potemplate

=== modified file 'lib/lp/registry/stories/webservice/xx-source-package.txt'
--- lib/lp/registry/stories/webservice/xx-source-package.txt 2010-05-17 09:35:18 +0000
+++ lib/lp/registry/stories/webservice/xx-source-package.txt 2010-05-18 15:23:51 +0000
@@ -130,10 +130,27 @@
 All translation templates for a source package are available at the
 'all_translation_templates' collection link.

+
+ >>> from zope.component import getUtility
+ >>> from canonical.launchpad.interfaces.launchpad import (
+ ... ILaunchpadCelebrities)
+ >>> from lp.registry.interfaces.sourcepackagename import (
+ ... ISourcePackageNameSet)
+ >>> from lp.translations.interfaces.potemplate import IPOTemplateSet
+ >>> login('<email address hidden>')
+ >>> hoary = getUtility(ILaunchpadCelebrities).ubuntu.getSeries('hoary')
+ >>> evolution_package = getUtility(ISourcePackageNameSet)['evolution']
+ >>> templates = getUtility(
+ ... IPOTemplateSet).getSubset(
+ ... distroseries=hoary,
+ ... sourcepackagename=evolution_package)
+ >>> db_count = len(list(templates))
+ >>> logout()
     >>> all_translation_templates = anon_webservice.get(
     ... evolution['self_link'] + '/all_translation_templates').jsonBody()
- >>> print all_translation_templates['total_size']
- 3
+ >>> api_count = all_translation_templates['total_size']
+ >>> api_count == db_count
+ True
     >>> print(all_translation_templates['entries'][0]['resource_type_link'])
     http://.../#potemplate

=== modified file 'lib/lp/translations/interfaces/webservice.py'
--- lib/lp/translations/interfaces/webservice.py 2010-03-08 21:06:34 +0000
+++ lib/lp/translations/interfaces/webservice.py 2010-05-17 10:27:14 +0000
@@ -1,6 +1,8 @@
 # Copyright 2009 Canonical Ltd. This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).

+# pylint: disable-msg=W0611
+
 """All the interfaces that are exposed through the webservice."""

 from lp.translations.interfaces.translationimportqueue import (

« Back to merge proposal