14
14
>>> from lp.registry.interfaces.sourcepackagename import (
15
15
... ISourcePackageNameSet)
16
16
>>> from lp.translations.publisher import TranslationsLayer
17
>>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
19
18
All the tests will be submitted as comming from the No Privilege person.
111
Let's check the traversal code.
113
>>> from zope.security.proxy import isinstance
114
>>> from lp.translations.browser.potemplate import POTemplateNavigation
115
>>> from lp.translations.model.pofile import POFile, DummyPOFile
117
First, what happens if we get any method that is not supported?
119
>>> request = LaunchpadTestRequest()
120
>>> request.method = 'PUT'
121
>>> navigation = POTemplateNavigation(potemplate, request)
122
>>> navigation.traverse('es')
123
Traceback (most recent call last):
125
AssertionError: We only know about GET, HEAD, and POST
127
But when we use a supported method, we get the right object.
129
>>> request.method = 'GET'
130
>>> isinstance(navigation.traverse('es'), POFile)
133
Now, we are going to select a POFile that doesn't exist yet in our database.
135
>>> isinstance(navigation.traverse('zh_TW'), DummyPOFile)
138
But if we do a POST, instead of getting a DummyPOFile object, we will get a
141
>>> request.method = 'POST'
142
>>> isinstance(navigation.traverse('zh_TW'), POFile)
145
110
And that's all, folks!