Merge lp:~henninge/launchpad/recife-pofile-creation into lp:~launchpad/launchpad/recife

Proposed by Henning Eggers
Status: Merged
Merged at revision: 9165
Proposed branch: lp:~henninge/launchpad/recife-pofile-creation
Merge into: lp:~launchpad/launchpad/recife
Diff against target: 160 lines (+81/-13)
1 file modified
lib/lp/translations/tests/test_pofile.py (+81/-13)
To merge this branch: bzr merge lp:~henninge/launchpad/recife-pofile-creation
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+33800@code.launchpad.net

Description of the change

This is a follow-up to this merge:
https://code.launchpad.net/~henninge/launchpad/bug-545354-enable-sharing/+merge/27123

It add tests that show that when a new POFile is created, it is also created in sharing sourcepackages and upstream projects. POTemplate._createPOFilesInSharingPOTemplates uses POTemplateSharingSubset.getSharingPOTemplates which implements finding sharing templates across source packages and upstream projects.

Run the new tests like this:

bin/test -vvcm lp.translations.tests.test_pofile -t test_pofile_creation_shared_

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Honourable of you to come back and add the tests. As per IRC, a few notes:
 * These templates are "sharing," not "shared." Because they share POTMsgSets, not because anyone shares the POTemplates.
 * You mention a POTemplate's name being "the same." Same as what?
 * Avoid looking up warty and hoary in the sample data. Just create new series.
 * Try shortcutting some of the setup by having your first makeSourcePackage call create your SourcePackageName (and perhaps DistroSeries) implicitly.
 * One of the missing articles in the test_pofile_creation_shared_in_ubuntu comment is confusing.

Apart from that, r=me.

review: Approve
Revision history for this message
Henning Eggers (henninge) wrote :

Am 27.08.2010 09:35, schrieb Jeroen T. Vermeulen:
> Review: Approve
> Honourable of you to come back and add the tests. As per IRC, a few notes:

Well, the original task was to implement this but I found that it already was
- just not tested... ;-)

> * These templates are "sharing," not "shared." Because they share POTMsgSets, not because anyone shares the POTemplates.
> * You mention a POTemplate's name being "the same." Same as what?
> * Avoid looking up warty and hoary in the sample data. Just create new series.

Did all these.

> * Try shortcutting some of the setup by having your first makeSourcePackage call create your SourcePackageName (and perhaps DistroSeries) implicitly.

Did a little of that.

> * One of the missing articles in the test_pofile_creation_shared_in_ubuntu comment is confusing.

Fixed.

>
> Apart from that, r=me.

Thank you very much!

Henning

=== modified file 'lib/lp/translations/tests/test_pofile.py'
--- lib/lp/translations/tests/test_pofile.py 2010-08-26 16:20:09 +0000
+++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:03:01 +0000
@@ -239,7 +239,7 @@
239 # Test the canonical_url of the POFile.239 # Test the canonical_url of the POFile.
240 pofile_url = (240 pofile_url = (
241 'http://translations.launchpad.dev/foo/devel/+pots/messages/'241 'http://translations.launchpad.dev/foo/devel/+pots/messages/'
242 '%s' % self.devel_pofile.language.code )242 '%s' % self.devel_pofile.language.code)
243 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))243 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))
244 view_name = '+details'244 view_name = '+details'
245 view_url = "%s/%s" % (pofile_url, view_name)245 view_url = "%s/%s" % (pofile_url, view_name)
@@ -919,15 +919,15 @@
919 "Diverged translation")])919 "Diverged translation")])
920920
921921
922class TestSharedPOFileCreation(TestCaseWithFactory):922class TestSharingPOFileCreation(TestCaseWithFactory):
923 """Test that POFiles are created in shared POTemplates."""923 """Test that POFiles are created in sharing POTemplates."""
924924
925 layer = ZopelessDatabaseLayer925 layer = ZopelessDatabaseLayer
926926
927 def setUp(self):927 def setUp(self):
928 # Create a product with two series and a shared POTemplate928 # Create a product with two series and a sharing POTemplate
929 # in different series ('devel' and 'stable').929 # in different series ('devel' and 'stable').
930 super(TestSharedPOFileCreation, self).setUp()930 super(TestSharingPOFileCreation, self).setUp()
931 self.foo = self.factory.makeProduct()931 self.foo = self.factory.makeProduct()
932 self.foo_devel = self.factory.makeProductSeries(932 self.foo_devel = self.factory.makeProductSeries(
933 name='devel', product=self.foo)933 name='devel', product=self.foo)
@@ -935,10 +935,10 @@
935 name='stable', product=self.foo)935 name='stable', product=self.foo)
936 self.foo.official_rosetta = True936 self.foo.official_rosetta = True
937937
938 def test_pofile_creation_shared(self):938 def test_pofile_creation_sharing(self):
939 # When a pofile is created in a POTemplate it is also created in939 # When a pofile is created in a POTemplate it is also created in
940 # all shared templates.940 # all sharing templates.
941 # POTemplate is 'shared' if it has the same name ('messages').941 # Two POTemplates are sharing if they have the same name ('messages').
942 devel_potemplate = self.factory.makePOTemplate(942 devel_potemplate = self.factory.makePOTemplate(
943 productseries=self.foo_devel, name="messages")943 productseries=self.foo_devel, name="messages")
944 stable_potemplate = self.factory.makePOTemplate(944 stable_potemplate = self.factory.makePOTemplate(
@@ -951,18 +951,20 @@
951 self.assertEqual(pofile_devel.language.code,951 self.assertEqual(pofile_devel.language.code,
952 pofile_stable.language.code)952 pofile_stable.language.code)
953953
954 def test_pofile_creation_shared_upstream(self):954 def test_pofile_creation_sharing_upstream(self):
955 # When a pofile is created in a POTemplate of an Ubuntu package955 # When a pofile is created in a POTemplate of an Ubuntu package
956 # it is also created in all shared templates in the upstream project.956 # it is also created in all shared templates in the upstream project.
957 # POTemplate is 'shared' if it has the same name ('messages').957 # POTemplate is 'shared' if it has the same name ('messages').
958 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu958 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
959 hoary = ubuntu ['hoary']959 distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
960 packagename = self.factory.makeSourcePackageName()960 ubuntu.translation_focus = distroseries
961 sourcepackage = self.factory.makeSourcePackage(packagename, hoary)961 sourcepackage = self.factory.makeSourcePackage(
962 distroseries=distroseries)
962 sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson())963 sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson())
963 sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson())964 sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson())
964 package_potemplate = self.factory.makePOTemplate(965 package_potemplate = self.factory.makePOTemplate(
965 distroseries=hoary, sourcepackagename=packagename,966 distroseries=distroseries,
967 sourcepackagename=sourcepackage.sourcepackagename,
966 name="messages")968 name="messages")
967 devel_potemplate = self.factory.makePOTemplate(969 devel_potemplate = self.factory.makePOTemplate(
968 productseries=self.foo_devel, name="messages")970 productseries=self.foo_devel, name="messages")
@@ -979,47 +981,46 @@
979 stable_pofile = stable_potemplate.getPOFileByLang('eo')981 stable_pofile = stable_potemplate.getPOFileByLang('eo')
980 self.assertNotEqual(None, stable_pofile)982 self.assertNotEqual(None, stable_pofile)
981983
982 def test_pofile_creation_shared_in_ubuntu(self):984 def test_pofile_creation_sharing_in_ubuntu(self):
983 # When a pofile is created in a POTemplate of project it is also985 # When a pofile is created in a POTemplate of a project it is also
984 # created in all shared templates in the linked Ubuntu package.986 # created in all sharing templates in the linked Ubuntu package.
985 # POTemplate is 'shared' if it has the same name ('messages').987 # Two POTemplates are sharing if they have the same name ('messages').
986 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu988 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
987 hoary = ubuntu ['hoary']989 distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu)
988 warty = ubuntu['warty']990 distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu)
989 packagename = self.factory.makeSourcePackageName()991 packagename = self.factory.makeSourcePackageName()
990 hoary_package = self.factory.makeSourcePackage(packagename, hoary)992 self.factory.makeSourcePackage(packagename, distroseries1)
991 warty_package = self.factory.makeSourcePackage(packagename, warty)993 self.factory.makeSourcePackage(packagename, distroseries2)
992 self.factory.makeSourcePackagePublishingHistory(994 self.factory.makeSourcePackagePublishingHistory(
993 sourcepackagename=packagename, distroseries=hoary)995 sourcepackagename=packagename, distroseries=distroseries1)
994 self.factory.makeSourcePackagePublishingHistory(996 self.factory.makeSourcePackagePublishingHistory(
995 sourcepackagename=packagename, distroseries=warty)997 sourcepackagename=packagename, distroseries=distroseries2)
996 owner = self.factory.makePerson()998 owner = self.factory.makePerson()
997 self.foo_stable.setPackaging(hoary, packagename, owner)999 self.foo_stable.setPackaging(distroseries1, packagename, owner)
998 self.foo_stable.setPackaging(warty, packagename, owner)1000 self.foo_stable.setPackaging(distroseries2, packagename, owner)
9991001
1000
1001 stable_potemplate = self.factory.makePOTemplate(1002 stable_potemplate = self.factory.makePOTemplate(
1002 productseries=self.foo_stable, name="messages")1003 productseries=self.foo_stable, name="messages")
1003 hoary_potemplate = self.factory.makePOTemplate(1004 distroseries1_potemplate = self.factory.makePOTemplate(
1004 distroseries=hoary, sourcepackagename=packagename,1005 distroseries=distroseries1, sourcepackagename=packagename,
1005 name="messages")1006 name="messages")
1006 warty_potemplate = self.factory.makePOTemplate(1007 distroseries2_potemplate = self.factory.makePOTemplate(
1007 distroseries=warty, sourcepackagename=packagename,1008 distroseries=distroseries2, sourcepackagename=packagename,
1008 name="messages")1009 name="messages")
10091010
1010 self.assertEqual(None, hoary_potemplate.getPOFileByLang('eo'))1011 self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo'))
1011 self.assertEqual(None, warty_potemplate.getPOFileByLang('eo'))1012 self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo'))
10121013
1013 stable_pofile = stable_potemplate.newPOFile('eo')1014 stable_pofile = stable_potemplate.newPOFile('eo')
10141015
1015 hoary_pofile = hoary_potemplate.getPOFileByLang('eo')1016 distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo')
1016 self.assertNotEqual(None, hoary_pofile)1017 self.assertNotEqual(None, distroseries1_pofile)
1017 warty_pofile = warty_potemplate.getPOFileByLang('eo')1018 distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo')
1018 self.assertNotEqual(None, warty_pofile)1019 self.assertNotEqual(None, distroseries2_pofile)
10191020
1020 def test_pofile_creation_not_shared(self):1021 def test_pofile_creation_not_sharing(self):
1021 # When a pofile is created in a POTemplate it is not created in1022 # When a pofile is created in a POTemplate it is not created in
1022 # other templates that are not shared.1023 # other templates that are not sharing.
1023 potemplate_devel_1 = self.factory.makePOTemplate(1024 potemplate_devel_1 = self.factory.makePOTemplate(
1024 productseries=self.foo_devel, name="template-1")1025 productseries=self.foo_devel, name="template-1")
1025 potemplate_stable_2 = self.factory.makePOTemplate(1026 potemplate_stable_2 = self.factory.makePOTemplate(
@@ -1031,7 +1032,7 @@
10311032
1032 def test_potemplate_creation(self):1033 def test_potemplate_creation(self):
1033 # When a potemplate is created it receives a copy of all pofiles in1034 # When a potemplate is created it receives a copy of all pofiles in
1034 # all shared potemplates.1035 # all sharing potemplates.
1035 foo_other = self.factory.makeProductSeries(1036 foo_other = self.factory.makeProductSeries(
1036 name='other', product=self.foo)1037 name='other', product=self.foo)
1037 self.factory.makePOTemplate(1038 self.factory.makePOTemplate(
@@ -1121,7 +1122,7 @@
1121 layer = ZopelessDatabaseLayer1122 layer = ZopelessDatabaseLayer
11221123
1123 def setUp(self):1124 def setUp(self):
1124 # Create a product with two series and a shared POTemplate1125 # Create a product with two series and a sharing POTemplate
1125 # in different series ('devel' and 'stable').1126 # in different series ('devel' and 'stable').
1126 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()1127 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()
1127 self.foo = self.factory.makeProduct()1128 self.foo = self.factory.makeProduct()
@@ -1131,7 +1132,7 @@
1131 name='stable', product=self.foo)1132 name='stable', product=self.foo)
1132 self.foo.official_rosetta = True1133 self.foo.official_rosetta = True
11331134
1134 # POTemplate is 'shared' if it has the same name ('messages').1135 # Two POTemplates are sharing if they have the same name ('messages').
1135 self.devel_potemplate = self.factory.makePOTemplate(1136 self.devel_potemplate = self.factory.makePOTemplate(
1136 productseries=self.foo_devel, name="messages")1137 productseries=self.foo_devel, name="messages")
1137 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,1138 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/translations/tests/test_pofile.py'
--- lib/lp/translations/tests/test_pofile.py 2010-08-24 07:12:53 +0000
+++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:07:46 +0000
@@ -18,6 +18,7 @@
18from zope.security.proxy import removeSecurityProxy18from zope.security.proxy import removeSecurityProxy
1919
20from canonical.database.constants import UTC_NOW20from canonical.database.constants import UTC_NOW
21from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
21from canonical.launchpad.webapp.publisher import canonical_url22from canonical.launchpad.webapp.publisher import canonical_url
22from canonical.testing import (23from canonical.testing import (
23 LaunchpadZopelessLayer,24 LaunchpadZopelessLayer,
@@ -238,7 +239,7 @@
238 # Test the canonical_url of the POFile.239 # Test the canonical_url of the POFile.
239 pofile_url = (240 pofile_url = (
240 'http://translations.launchpad.dev/foo/devel/+pots/messages/'241 'http://translations.launchpad.dev/foo/devel/+pots/messages/'
241 '%s' % self.devel_pofile.language.code )242 '%s' % self.devel_pofile.language.code)
242 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))243 self.assertEqual(pofile_url, canonical_url(self.devel_pofile))
243 view_name = '+details'244 view_name = '+details'
244 view_url = "%s/%s" % (pofile_url, view_name)245 view_url = "%s/%s" % (pofile_url, view_name)
@@ -918,15 +919,15 @@
918 "Diverged translation")])919 "Diverged translation")])
919920
920921
921class TestSharedPOFileCreation(TestCaseWithFactory):922class TestSharingPOFileCreation(TestCaseWithFactory):
922 """Test that POFiles are created in shared POTemplates."""923 """Test that POFiles are created in sharing POTemplates."""
923924
924 layer = ZopelessDatabaseLayer925 layer = ZopelessDatabaseLayer
925926
926 def setUp(self):927 def setUp(self):
927 # Create a product with two series and a shared POTemplate928 # Create a product with two series and a sharing POTemplate
928 # in different series ('devel' and 'stable').929 # in different series ('devel' and 'stable').
929 super(TestSharedPOFileCreation, self).setUp()930 super(TestSharingPOFileCreation, self).setUp()
930 self.foo = self.factory.makeProduct()931 self.foo = self.factory.makeProduct()
931 self.foo_devel = self.factory.makeProductSeries(932 self.foo_devel = self.factory.makeProductSeries(
932 name='devel', product=self.foo)933 name='devel', product=self.foo)
@@ -934,10 +935,10 @@
934 name='stable', product=self.foo)935 name='stable', product=self.foo)
935 self.foo.official_rosetta = True936 self.foo.official_rosetta = True
936937
937 def test_pofile_creation_shared(self):938 def test_pofile_creation_sharing(self):
938 # When a pofile is created in a POTemplate it is also created in939 # When a pofile is created in a POTemplate it is also created in
939 # all shared templates.940 # all sharing templates.
940 # POTemplate is 'shared' if it has the same name ('messages').941 # Two POTemplates are sharing if they have the same name ('messages').
941 devel_potemplate = self.factory.makePOTemplate(942 devel_potemplate = self.factory.makePOTemplate(
942 productseries=self.foo_devel, name="messages")943 productseries=self.foo_devel, name="messages")
943 stable_potemplate = self.factory.makePOTemplate(944 stable_potemplate = self.factory.makePOTemplate(
@@ -950,9 +951,76 @@
950 self.assertEqual(pofile_devel.language.code,951 self.assertEqual(pofile_devel.language.code,
951 pofile_stable.language.code)952 pofile_stable.language.code)
952953
953 def test_pofile_creation_not_shared(self):954 def test_pofile_creation_sharing_upstream(self):
955 # When a pofile is created in a POTemplate of an Ubuntu package
956 # it is also created in all shared templates in the upstream project.
957 # POTemplate is 'shared' if it has the same name ('messages').
958 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
959 distroseries = self.factory.makeDistroSeries(distribution=ubuntu)
960 ubuntu.translation_focus = distroseries
961 sourcepackage = self.factory.makeSourcePackage(
962 distroseries=distroseries)
963 sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson())
964 sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson())
965 package_potemplate = self.factory.makePOTemplate(
966 distroseries=distroseries,
967 sourcepackagename=sourcepackage.sourcepackagename,
968 name="messages")
969 devel_potemplate = self.factory.makePOTemplate(
970 productseries=self.foo_devel, name="messages")
971 stable_potemplate = self.factory.makePOTemplate(
972 productseries=self.foo_stable, name="messages")
973
974 self.assertEqual(None, devel_potemplate.getPOFileByLang('eo'))
975 self.assertEqual(None, stable_potemplate.getPOFileByLang('eo'))
976
977 package_pofile = package_potemplate.newPOFile('eo')
978
979 devel_pofile = devel_potemplate.getPOFileByLang('eo')
980 self.assertNotEqual(None, devel_pofile)
981 stable_pofile = stable_potemplate.getPOFileByLang('eo')
982 self.assertNotEqual(None, stable_pofile)
983
984 def test_pofile_creation_sharing_in_ubuntu(self):
985 # When a pofile is created in a POTemplate of a project it is also
986 # created in all sharing templates in the linked Ubuntu package.
987 # Two POTemplates are sharing if they have the same name ('messages').
988 ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
989 distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu)
990 distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu)
991 packagename = self.factory.makeSourcePackageName()
992 self.factory.makeSourcePackage(packagename, distroseries1)
993 self.factory.makeSourcePackage(packagename, distroseries2)
994 self.factory.makeSourcePackagePublishingHistory(
995 sourcepackagename=packagename, distroseries=distroseries1)
996 self.factory.makeSourcePackagePublishingHistory(
997 sourcepackagename=packagename, distroseries=distroseries2)
998 owner = self.factory.makePerson()
999 self.foo_stable.setPackaging(distroseries1, packagename, owner)
1000 self.foo_stable.setPackaging(distroseries2, packagename, owner)
1001
1002 stable_potemplate = self.factory.makePOTemplate(
1003 productseries=self.foo_stable, name="messages")
1004 distroseries1_potemplate = self.factory.makePOTemplate(
1005 distroseries=distroseries1, sourcepackagename=packagename,
1006 name="messages")
1007 distroseries2_potemplate = self.factory.makePOTemplate(
1008 distroseries=distroseries2, sourcepackagename=packagename,
1009 name="messages")
1010
1011 self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo'))
1012 self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo'))
1013
1014 stable_pofile = stable_potemplate.newPOFile('eo')
1015
1016 distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo')
1017 self.assertNotEqual(None, distroseries1_pofile)
1018 distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo')
1019 self.assertNotEqual(None, distroseries2_pofile)
1020
1021 def test_pofile_creation_not_sharing(self):
954 # When a pofile is created in a POTemplate it is not created in1022 # When a pofile is created in a POTemplate it is not created in
955 # other templates that are not shared.1023 # other templates that are not sharing.
956 potemplate_devel_1 = self.factory.makePOTemplate(1024 potemplate_devel_1 = self.factory.makePOTemplate(
957 productseries=self.foo_devel, name="template-1")1025 productseries=self.foo_devel, name="template-1")
958 potemplate_stable_2 = self.factory.makePOTemplate(1026 potemplate_stable_2 = self.factory.makePOTemplate(
@@ -964,7 +1032,7 @@
9641032
965 def test_potemplate_creation(self):1033 def test_potemplate_creation(self):
966 # When a potemplate is created it receives a copy of all pofiles in1034 # When a potemplate is created it receives a copy of all pofiles in
967 # all shared potemplates.1035 # all sharing potemplates.
968 foo_other = self.factory.makeProductSeries(1036 foo_other = self.factory.makeProductSeries(
969 name='other', product=self.foo)1037 name='other', product=self.foo)
970 self.factory.makePOTemplate(1038 self.factory.makePOTemplate(
@@ -1054,7 +1122,7 @@
1054 layer = ZopelessDatabaseLayer1122 layer = ZopelessDatabaseLayer
10551123
1056 def setUp(self):1124 def setUp(self):
1057 # Create a product with two series and a shared POTemplate1125 # Create a product with two series and a sharing POTemplate
1058 # in different series ('devel' and 'stable').1126 # in different series ('devel' and 'stable').
1059 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()1127 super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp()
1060 self.foo = self.factory.makeProduct()1128 self.foo = self.factory.makeProduct()
@@ -1064,7 +1132,7 @@
1064 name='stable', product=self.foo)1132 name='stable', product=self.foo)
1065 self.foo.official_rosetta = True1133 self.foo.official_rosetta = True
10661134
1067 # POTemplate is 'shared' if it has the same name ('messages').1135 # Two POTemplates are sharing if they have the same name ('messages').
1068 self.devel_potemplate = self.factory.makePOTemplate(1136 self.devel_potemplate = self.factory.makePOTemplate(
1069 productseries=self.foo_devel, name="messages")1137 productseries=self.foo_devel, name="messages")
1070 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,1138 self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable,

Subscribers

People subscribed via source and target branches