Merge lp:~henninge/launchpad/recife-pofile-creation into lp:~launchpad/launchpad/recife
- recife-pofile-creation
- Merge into recife
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jeroen T. Vermeulen (community) | Approve | ||
Review via email: mp+33800@code.launchpad.net |
Commit message
Description of the change
This is a follow-up to this merge:
https:/
It add tests that show that when a new POFile is created, it is also created in sharing sourcepackages and upstream projects. POTemplate.
Run the new tests like this:
bin/test -vvcm lp.translations
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_
Fixed.
>
> Apart from that, r=me.
Thank you very much!
Henning
1 | === modified file 'lib/lp/translations/tests/test_pofile.py' | |||
2 | --- lib/lp/translations/tests/test_pofile.py 2010-08-26 16:20:09 +0000 | |||
3 | +++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:03:01 +0000 | |||
4 | @@ -239,7 +239,7 @@ | |||
5 | 239 | # Test the canonical_url of the POFile. | 239 | # Test the canonical_url of the POFile. |
6 | 240 | pofile_url = ( | 240 | pofile_url = ( |
7 | 241 | 'http://translations.launchpad.dev/foo/devel/+pots/messages/' | 241 | 'http://translations.launchpad.dev/foo/devel/+pots/messages/' |
9 | 242 | '%s' % self.devel_pofile.language.code ) | 242 | '%s' % self.devel_pofile.language.code) |
10 | 243 | self.assertEqual(pofile_url, canonical_url(self.devel_pofile)) | 243 | self.assertEqual(pofile_url, canonical_url(self.devel_pofile)) |
11 | 244 | view_name = '+details' | 244 | view_name = '+details' |
12 | 245 | view_url = "%s/%s" % (pofile_url, view_name) | 245 | view_url = "%s/%s" % (pofile_url, view_name) |
13 | @@ -919,15 +919,15 @@ | |||
14 | 919 | "Diverged translation")]) | 919 | "Diverged translation")]) |
15 | 920 | 920 | ||
16 | 921 | 921 | ||
19 | 922 | class TestSharedPOFileCreation(TestCaseWithFactory): | 922 | class TestSharingPOFileCreation(TestCaseWithFactory): |
20 | 923 | """Test that POFiles are created in shared POTemplates.""" | 923 | """Test that POFiles are created in sharing POTemplates.""" |
21 | 924 | 924 | ||
22 | 925 | layer = ZopelessDatabaseLayer | 925 | layer = ZopelessDatabaseLayer |
23 | 926 | 926 | ||
24 | 927 | def setUp(self): | 927 | def setUp(self): |
26 | 928 | # Create a product with two series and a shared POTemplate | 928 | # Create a product with two series and a sharing POTemplate |
27 | 929 | # in different series ('devel' and 'stable'). | 929 | # in different series ('devel' and 'stable'). |
29 | 930 | super(TestSharedPOFileCreation, self).setUp() | 930 | super(TestSharingPOFileCreation, self).setUp() |
30 | 931 | self.foo = self.factory.makeProduct() | 931 | self.foo = self.factory.makeProduct() |
31 | 932 | self.foo_devel = self.factory.makeProductSeries( | 932 | self.foo_devel = self.factory.makeProductSeries( |
32 | 933 | name='devel', product=self.foo) | 933 | name='devel', product=self.foo) |
33 | @@ -935,10 +935,10 @@ | |||
34 | 935 | name='stable', product=self.foo) | 935 | name='stable', product=self.foo) |
35 | 936 | self.foo.official_rosetta = True | 936 | self.foo.official_rosetta = True |
36 | 937 | 937 | ||
38 | 938 | def test_pofile_creation_shared(self): | 938 | def test_pofile_creation_sharing(self): |
39 | 939 | # When a pofile is created in a POTemplate it is also created in | 939 | # When a pofile is created in a POTemplate it is also created in |
42 | 940 | # all shared templates. | 940 | # all sharing templates. |
43 | 941 | # POTemplate is 'shared' if it has the same name ('messages'). | 941 | # Two POTemplates are sharing if they have the same name ('messages'). |
44 | 942 | devel_potemplate = self.factory.makePOTemplate( | 942 | devel_potemplate = self.factory.makePOTemplate( |
45 | 943 | productseries=self.foo_devel, name="messages") | 943 | productseries=self.foo_devel, name="messages") |
46 | 944 | stable_potemplate = self.factory.makePOTemplate( | 944 | stable_potemplate = self.factory.makePOTemplate( |
47 | @@ -951,18 +951,20 @@ | |||
48 | 951 | self.assertEqual(pofile_devel.language.code, | 951 | self.assertEqual(pofile_devel.language.code, |
49 | 952 | pofile_stable.language.code) | 952 | pofile_stable.language.code) |
50 | 953 | 953 | ||
52 | 954 | def test_pofile_creation_shared_upstream(self): | 954 | def test_pofile_creation_sharing_upstream(self): |
53 | 955 | # When a pofile is created in a POTemplate of an Ubuntu package | 955 | # When a pofile is created in a POTemplate of an Ubuntu package |
54 | 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. |
55 | 957 | # POTemplate is 'shared' if it has the same name ('messages'). | 957 | # POTemplate is 'shared' if it has the same name ('messages'). |
56 | 958 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu | 958 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu |
60 | 959 | hoary = ubuntu ['hoary'] | 959 | distroseries = self.factory.makeDistroSeries(distribution=ubuntu) |
61 | 960 | packagename = self.factory.makeSourcePackageName() | 960 | ubuntu.translation_focus = distroseries |
62 | 961 | sourcepackage = self.factory.makeSourcePackage(packagename, hoary) | 961 | sourcepackage = self.factory.makeSourcePackage( |
63 | 962 | distroseries=distroseries) | ||
64 | 962 | sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson()) | 963 | sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson()) |
65 | 963 | sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson()) | 964 | sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson()) |
66 | 964 | package_potemplate = self.factory.makePOTemplate( | 965 | package_potemplate = self.factory.makePOTemplate( |
68 | 965 | distroseries=hoary, sourcepackagename=packagename, | 966 | distroseries=distroseries, |
69 | 967 | sourcepackagename=sourcepackage.sourcepackagename, | ||
70 | 966 | name="messages") | 968 | name="messages") |
71 | 967 | devel_potemplate = self.factory.makePOTemplate( | 969 | devel_potemplate = self.factory.makePOTemplate( |
72 | 968 | productseries=self.foo_devel, name="messages") | 970 | productseries=self.foo_devel, name="messages") |
73 | @@ -979,47 +981,46 @@ | |||
74 | 979 | stable_pofile = stable_potemplate.getPOFileByLang('eo') | 981 | stable_pofile = stable_potemplate.getPOFileByLang('eo') |
75 | 980 | self.assertNotEqual(None, stable_pofile) | 982 | self.assertNotEqual(None, stable_pofile) |
76 | 981 | 983 | ||
81 | 982 | def test_pofile_creation_shared_in_ubuntu(self): | 984 | def test_pofile_creation_sharing_in_ubuntu(self): |
82 | 983 | # When a pofile is created in a POTemplate of project it is also | 985 | # When a pofile is created in a POTemplate of a project it is also |
83 | 984 | # created in all shared templates in the linked Ubuntu package. | 986 | # created in all sharing templates in the linked Ubuntu package. |
84 | 985 | # POTemplate is 'shared' if it has the same name ('messages'). | 987 | # Two POTemplates are sharing if they have the same name ('messages'). |
85 | 986 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu | 988 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu |
88 | 987 | hoary = ubuntu ['hoary'] | 989 | distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu) |
89 | 988 | warty = ubuntu['warty'] | 990 | distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu) |
90 | 989 | packagename = self.factory.makeSourcePackageName() | 991 | packagename = self.factory.makeSourcePackageName() |
97 | 990 | hoary_package = self.factory.makeSourcePackage(packagename, hoary) | 992 | self.factory.makeSourcePackage(packagename, distroseries1) |
98 | 991 | warty_package = self.factory.makeSourcePackage(packagename, warty) | 993 | self.factory.makeSourcePackage(packagename, distroseries2) |
99 | 992 | self.factory.makeSourcePackagePublishingHistory( | 994 | self.factory.makeSourcePackagePublishingHistory( |
100 | 993 | sourcepackagename=packagename, distroseries=hoary) | 995 | sourcepackagename=packagename, distroseries=distroseries1) |
101 | 994 | self.factory.makeSourcePackagePublishingHistory( | 996 | self.factory.makeSourcePackagePublishingHistory( |
102 | 995 | sourcepackagename=packagename, distroseries=warty) | 997 | sourcepackagename=packagename, distroseries=distroseries2) |
103 | 996 | owner = self.factory.makePerson() | 998 | owner = self.factory.makePerson() |
106 | 997 | self.foo_stable.setPackaging(hoary, packagename, owner) | 999 | self.foo_stable.setPackaging(distroseries1, packagename, owner) |
107 | 998 | self.foo_stable.setPackaging(warty, packagename, owner) | 1000 | self.foo_stable.setPackaging(distroseries2, packagename, owner) |
108 | 999 | 1001 | ||
109 | 1000 | |||
110 | 1001 | stable_potemplate = self.factory.makePOTemplate( | 1002 | stable_potemplate = self.factory.makePOTemplate( |
111 | 1002 | productseries=self.foo_stable, name="messages") | 1003 | productseries=self.foo_stable, name="messages") |
114 | 1003 | hoary_potemplate = self.factory.makePOTemplate( | 1004 | distroseries1_potemplate = self.factory.makePOTemplate( |
115 | 1004 | distroseries=hoary, sourcepackagename=packagename, | 1005 | distroseries=distroseries1, sourcepackagename=packagename, |
116 | 1005 | name="messages") | 1006 | name="messages") |
119 | 1006 | warty_potemplate = self.factory.makePOTemplate( | 1007 | distroseries2_potemplate = self.factory.makePOTemplate( |
120 | 1007 | distroseries=warty, sourcepackagename=packagename, | 1008 | distroseries=distroseries2, sourcepackagename=packagename, |
121 | 1008 | name="messages") | 1009 | name="messages") |
122 | 1009 | 1010 | ||
125 | 1010 | self.assertEqual(None, hoary_potemplate.getPOFileByLang('eo')) | 1011 | self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo')) |
126 | 1011 | self.assertEqual(None, warty_potemplate.getPOFileByLang('eo')) | 1012 | self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo')) |
127 | 1012 | 1013 | ||
128 | 1013 | stable_pofile = stable_potemplate.newPOFile('eo') | 1014 | stable_pofile = stable_potemplate.newPOFile('eo') |
129 | 1014 | 1015 | ||
134 | 1015 | hoary_pofile = hoary_potemplate.getPOFileByLang('eo') | 1016 | distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo') |
135 | 1016 | self.assertNotEqual(None, hoary_pofile) | 1017 | self.assertNotEqual(None, distroseries1_pofile) |
136 | 1017 | warty_pofile = warty_potemplate.getPOFileByLang('eo') | 1018 | distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo') |
137 | 1018 | self.assertNotEqual(None, warty_pofile) | 1019 | self.assertNotEqual(None, distroseries2_pofile) |
138 | 1019 | 1020 | ||
140 | 1020 | def test_pofile_creation_not_shared(self): | 1021 | def test_pofile_creation_not_sharing(self): |
141 | 1021 | # When a pofile is created in a POTemplate it is not created in | 1022 | # When a pofile is created in a POTemplate it is not created in |
143 | 1022 | # other templates that are not shared. | 1023 | # other templates that are not sharing. |
144 | 1023 | potemplate_devel_1 = self.factory.makePOTemplate( | 1024 | potemplate_devel_1 = self.factory.makePOTemplate( |
145 | 1024 | productseries=self.foo_devel, name="template-1") | 1025 | productseries=self.foo_devel, name="template-1") |
146 | 1025 | potemplate_stable_2 = self.factory.makePOTemplate( | 1026 | potemplate_stable_2 = self.factory.makePOTemplate( |
147 | @@ -1031,7 +1032,7 @@ | |||
148 | 1031 | 1032 | ||
149 | 1032 | def test_potemplate_creation(self): | 1033 | def test_potemplate_creation(self): |
150 | 1033 | # When a potemplate is created it receives a copy of all pofiles in | 1034 | # When a potemplate is created it receives a copy of all pofiles in |
152 | 1034 | # all shared potemplates. | 1035 | # all sharing potemplates. |
153 | 1035 | foo_other = self.factory.makeProductSeries( | 1036 | foo_other = self.factory.makeProductSeries( |
154 | 1036 | name='other', product=self.foo) | 1037 | name='other', product=self.foo) |
155 | 1037 | self.factory.makePOTemplate( | 1038 | self.factory.makePOTemplate( |
156 | @@ -1121,7 +1122,7 @@ | |||
157 | 1121 | layer = ZopelessDatabaseLayer | 1122 | layer = ZopelessDatabaseLayer |
158 | 1122 | 1123 | ||
159 | 1123 | def setUp(self): | 1124 | def setUp(self): |
161 | 1124 | # Create a product with two series and a shared POTemplate | 1125 | # Create a product with two series and a sharing POTemplate |
162 | 1125 | # in different series ('devel' and 'stable'). | 1126 | # in different series ('devel' and 'stable'). |
163 | 1126 | super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp() | 1127 | super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp() |
164 | 1127 | self.foo = self.factory.makeProduct() | 1128 | self.foo = self.factory.makeProduct() |
165 | @@ -1131,7 +1132,7 @@ | |||
166 | 1131 | name='stable', product=self.foo) | 1132 | name='stable', product=self.foo) |
167 | 1132 | self.foo.official_rosetta = True | 1133 | self.foo.official_rosetta = True |
168 | 1133 | 1134 | ||
170 | 1134 | # POTemplate is 'shared' if it has the same name ('messages'). | 1135 | # Two POTemplates are sharing if they have the same name ('messages'). |
171 | 1135 | self.devel_potemplate = self.factory.makePOTemplate( | 1136 | self.devel_potemplate = self.factory.makePOTemplate( |
172 | 1136 | productseries=self.foo_devel, name="messages") | 1137 | productseries=self.foo_devel, name="messages") |
173 | 1137 | self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable, | 1138 | self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable, |
Preview Diff
1 | === modified file 'lib/lp/translations/tests/test_pofile.py' | |||
2 | --- lib/lp/translations/tests/test_pofile.py 2010-08-24 07:12:53 +0000 | |||
3 | +++ lib/lp/translations/tests/test_pofile.py 2010-08-27 10:07:46 +0000 | |||
4 | @@ -18,6 +18,7 @@ | |||
5 | 18 | from zope.security.proxy import removeSecurityProxy | 18 | from zope.security.proxy import removeSecurityProxy |
6 | 19 | 19 | ||
7 | 20 | from canonical.database.constants import UTC_NOW | 20 | from canonical.database.constants import UTC_NOW |
8 | 21 | from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities | ||
9 | 21 | from canonical.launchpad.webapp.publisher import canonical_url | 22 | from canonical.launchpad.webapp.publisher import canonical_url |
10 | 22 | from canonical.testing import ( | 23 | from canonical.testing import ( |
11 | 23 | LaunchpadZopelessLayer, | 24 | LaunchpadZopelessLayer, |
12 | @@ -238,7 +239,7 @@ | |||
13 | 238 | # Test the canonical_url of the POFile. | 239 | # Test the canonical_url of the POFile. |
14 | 239 | pofile_url = ( | 240 | pofile_url = ( |
15 | 240 | 'http://translations.launchpad.dev/foo/devel/+pots/messages/' | 241 | 'http://translations.launchpad.dev/foo/devel/+pots/messages/' |
17 | 241 | '%s' % self.devel_pofile.language.code ) | 242 | '%s' % self.devel_pofile.language.code) |
18 | 242 | self.assertEqual(pofile_url, canonical_url(self.devel_pofile)) | 243 | self.assertEqual(pofile_url, canonical_url(self.devel_pofile)) |
19 | 243 | view_name = '+details' | 244 | view_name = '+details' |
20 | 244 | view_url = "%s/%s" % (pofile_url, view_name) | 245 | view_url = "%s/%s" % (pofile_url, view_name) |
21 | @@ -918,15 +919,15 @@ | |||
22 | 918 | "Diverged translation")]) | 919 | "Diverged translation")]) |
23 | 919 | 920 | ||
24 | 920 | 921 | ||
27 | 921 | class TestSharedPOFileCreation(TestCaseWithFactory): | 922 | class TestSharingPOFileCreation(TestCaseWithFactory): |
28 | 922 | """Test that POFiles are created in shared POTemplates.""" | 923 | """Test that POFiles are created in sharing POTemplates.""" |
29 | 923 | 924 | ||
30 | 924 | layer = ZopelessDatabaseLayer | 925 | layer = ZopelessDatabaseLayer |
31 | 925 | 926 | ||
32 | 926 | def setUp(self): | 927 | def setUp(self): |
34 | 927 | # Create a product with two series and a shared POTemplate | 928 | # Create a product with two series and a sharing POTemplate |
35 | 928 | # in different series ('devel' and 'stable'). | 929 | # in different series ('devel' and 'stable'). |
37 | 929 | super(TestSharedPOFileCreation, self).setUp() | 930 | super(TestSharingPOFileCreation, self).setUp() |
38 | 930 | self.foo = self.factory.makeProduct() | 931 | self.foo = self.factory.makeProduct() |
39 | 931 | self.foo_devel = self.factory.makeProductSeries( | 932 | self.foo_devel = self.factory.makeProductSeries( |
40 | 932 | name='devel', product=self.foo) | 933 | name='devel', product=self.foo) |
41 | @@ -934,10 +935,10 @@ | |||
42 | 934 | name='stable', product=self.foo) | 935 | name='stable', product=self.foo) |
43 | 935 | self.foo.official_rosetta = True | 936 | self.foo.official_rosetta = True |
44 | 936 | 937 | ||
46 | 937 | def test_pofile_creation_shared(self): | 938 | def test_pofile_creation_sharing(self): |
47 | 938 | # When a pofile is created in a POTemplate it is also created in | 939 | # When a pofile is created in a POTemplate it is also created in |
50 | 939 | # all shared templates. | 940 | # all sharing templates. |
51 | 940 | # POTemplate is 'shared' if it has the same name ('messages'). | 941 | # Two POTemplates are sharing if they have the same name ('messages'). |
52 | 941 | devel_potemplate = self.factory.makePOTemplate( | 942 | devel_potemplate = self.factory.makePOTemplate( |
53 | 942 | productseries=self.foo_devel, name="messages") | 943 | productseries=self.foo_devel, name="messages") |
54 | 943 | stable_potemplate = self.factory.makePOTemplate( | 944 | stable_potemplate = self.factory.makePOTemplate( |
55 | @@ -950,9 +951,76 @@ | |||
56 | 950 | self.assertEqual(pofile_devel.language.code, | 951 | self.assertEqual(pofile_devel.language.code, |
57 | 951 | pofile_stable.language.code) | 952 | pofile_stable.language.code) |
58 | 952 | 953 | ||
60 | 953 | def test_pofile_creation_not_shared(self): | 954 | def test_pofile_creation_sharing_upstream(self): |
61 | 955 | # When a pofile is created in a POTemplate of an Ubuntu package | ||
62 | 956 | # it is also created in all shared templates in the upstream project. | ||
63 | 957 | # POTemplate is 'shared' if it has the same name ('messages'). | ||
64 | 958 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu | ||
65 | 959 | distroseries = self.factory.makeDistroSeries(distribution=ubuntu) | ||
66 | 960 | ubuntu.translation_focus = distroseries | ||
67 | 961 | sourcepackage = self.factory.makeSourcePackage( | ||
68 | 962 | distroseries=distroseries) | ||
69 | 963 | sourcepackage.setPackaging(self.foo_devel, self.factory.makePerson()) | ||
70 | 964 | sourcepackage.setPackaging(self.foo_stable, self.factory.makePerson()) | ||
71 | 965 | package_potemplate = self.factory.makePOTemplate( | ||
72 | 966 | distroseries=distroseries, | ||
73 | 967 | sourcepackagename=sourcepackage.sourcepackagename, | ||
74 | 968 | name="messages") | ||
75 | 969 | devel_potemplate = self.factory.makePOTemplate( | ||
76 | 970 | productseries=self.foo_devel, name="messages") | ||
77 | 971 | stable_potemplate = self.factory.makePOTemplate( | ||
78 | 972 | productseries=self.foo_stable, name="messages") | ||
79 | 973 | |||
80 | 974 | self.assertEqual(None, devel_potemplate.getPOFileByLang('eo')) | ||
81 | 975 | self.assertEqual(None, stable_potemplate.getPOFileByLang('eo')) | ||
82 | 976 | |||
83 | 977 | package_pofile = package_potemplate.newPOFile('eo') | ||
84 | 978 | |||
85 | 979 | devel_pofile = devel_potemplate.getPOFileByLang('eo') | ||
86 | 980 | self.assertNotEqual(None, devel_pofile) | ||
87 | 981 | stable_pofile = stable_potemplate.getPOFileByLang('eo') | ||
88 | 982 | self.assertNotEqual(None, stable_pofile) | ||
89 | 983 | |||
90 | 984 | def test_pofile_creation_sharing_in_ubuntu(self): | ||
91 | 985 | # When a pofile is created in a POTemplate of a project it is also | ||
92 | 986 | # created in all sharing templates in the linked Ubuntu package. | ||
93 | 987 | # Two POTemplates are sharing if they have the same name ('messages'). | ||
94 | 988 | ubuntu = getUtility(ILaunchpadCelebrities).ubuntu | ||
95 | 989 | distroseries1 = self.factory.makeDistroSeries(distribution=ubuntu) | ||
96 | 990 | distroseries2 = self.factory.makeDistroSeries(distribution=ubuntu) | ||
97 | 991 | packagename = self.factory.makeSourcePackageName() | ||
98 | 992 | self.factory.makeSourcePackage(packagename, distroseries1) | ||
99 | 993 | self.factory.makeSourcePackage(packagename, distroseries2) | ||
100 | 994 | self.factory.makeSourcePackagePublishingHistory( | ||
101 | 995 | sourcepackagename=packagename, distroseries=distroseries1) | ||
102 | 996 | self.factory.makeSourcePackagePublishingHistory( | ||
103 | 997 | sourcepackagename=packagename, distroseries=distroseries2) | ||
104 | 998 | owner = self.factory.makePerson() | ||
105 | 999 | self.foo_stable.setPackaging(distroseries1, packagename, owner) | ||
106 | 1000 | self.foo_stable.setPackaging(distroseries2, packagename, owner) | ||
107 | 1001 | |||
108 | 1002 | stable_potemplate = self.factory.makePOTemplate( | ||
109 | 1003 | productseries=self.foo_stable, name="messages") | ||
110 | 1004 | distroseries1_potemplate = self.factory.makePOTemplate( | ||
111 | 1005 | distroseries=distroseries1, sourcepackagename=packagename, | ||
112 | 1006 | name="messages") | ||
113 | 1007 | distroseries2_potemplate = self.factory.makePOTemplate( | ||
114 | 1008 | distroseries=distroseries2, sourcepackagename=packagename, | ||
115 | 1009 | name="messages") | ||
116 | 1010 | |||
117 | 1011 | self.assertEqual(None, distroseries1_potemplate.getPOFileByLang('eo')) | ||
118 | 1012 | self.assertEqual(None, distroseries2_potemplate.getPOFileByLang('eo')) | ||
119 | 1013 | |||
120 | 1014 | stable_pofile = stable_potemplate.newPOFile('eo') | ||
121 | 1015 | |||
122 | 1016 | distroseries1_pofile = distroseries1_potemplate.getPOFileByLang('eo') | ||
123 | 1017 | self.assertNotEqual(None, distroseries1_pofile) | ||
124 | 1018 | distroseries2_pofile = distroseries2_potemplate.getPOFileByLang('eo') | ||
125 | 1019 | self.assertNotEqual(None, distroseries2_pofile) | ||
126 | 1020 | |||
127 | 1021 | def test_pofile_creation_not_sharing(self): | ||
128 | 954 | # When a pofile is created in a POTemplate it is not created in | 1022 | # When a pofile is created in a POTemplate it is not created in |
130 | 955 | # other templates that are not shared. | 1023 | # other templates that are not sharing. |
131 | 956 | potemplate_devel_1 = self.factory.makePOTemplate( | 1024 | potemplate_devel_1 = self.factory.makePOTemplate( |
132 | 957 | productseries=self.foo_devel, name="template-1") | 1025 | productseries=self.foo_devel, name="template-1") |
133 | 958 | potemplate_stable_2 = self.factory.makePOTemplate( | 1026 | potemplate_stable_2 = self.factory.makePOTemplate( |
134 | @@ -964,7 +1032,7 @@ | |||
135 | 964 | 1032 | ||
136 | 965 | def test_potemplate_creation(self): | 1033 | def test_potemplate_creation(self): |
137 | 966 | # When a potemplate is created it receives a copy of all pofiles in | 1034 | # When a potemplate is created it receives a copy of all pofiles in |
139 | 967 | # all shared potemplates. | 1035 | # all sharing potemplates. |
140 | 968 | foo_other = self.factory.makeProductSeries( | 1036 | foo_other = self.factory.makeProductSeries( |
141 | 969 | name='other', product=self.foo) | 1037 | name='other', product=self.foo) |
142 | 970 | self.factory.makePOTemplate( | 1038 | self.factory.makePOTemplate( |
143 | @@ -1054,7 +1122,7 @@ | |||
144 | 1054 | layer = ZopelessDatabaseLayer | 1122 | layer = ZopelessDatabaseLayer |
145 | 1055 | 1123 | ||
146 | 1056 | def setUp(self): | 1124 | def setUp(self): |
148 | 1057 | # Create a product with two series and a shared POTemplate | 1125 | # Create a product with two series and a sharing POTemplate |
149 | 1058 | # in different series ('devel' and 'stable'). | 1126 | # in different series ('devel' and 'stable'). |
150 | 1059 | super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp() | 1127 | super(TestTranslationPOFilePOTMsgSetOrdering, self).setUp() |
151 | 1060 | self.foo = self.factory.makeProduct() | 1128 | self.foo = self.factory.makeProduct() |
152 | @@ -1064,7 +1132,7 @@ | |||
153 | 1064 | name='stable', product=self.foo) | 1132 | name='stable', product=self.foo) |
154 | 1065 | self.foo.official_rosetta = True | 1133 | self.foo.official_rosetta = True |
155 | 1066 | 1134 | ||
157 | 1067 | # POTemplate is 'shared' if it has the same name ('messages'). | 1135 | # Two POTemplates are sharing if they have the same name ('messages'). |
158 | 1068 | self.devel_potemplate = self.factory.makePOTemplate( | 1136 | self.devel_potemplate = self.factory.makePOTemplate( |
159 | 1069 | productseries=self.foo_devel, name="messages") | 1137 | productseries=self.foo_devel, name="messages") |
160 | 1070 | self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable, | 1138 | self.stable_potemplate = self.factory.makePOTemplate(self.foo_stable, |
Honourable of you to come back and add the tests. As per IRC, a few notes: creation_ shared_ in_ubuntu comment is confusing.
* 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_
Apart from that, r=me.